Closed smjacques closed 2 years ago
putting on the beginning of the file options(stringsAsFactors = FALSE)
(cancelling the usage of factors), makes it work. But then it is a little bit slower. Why not using data.table ? :rocket:
I would be happy to know how to edit a package, right now I copied all the functions at the beginning of my script and did it with print debugging
with
cat('\n\n')
cat(paste(str(dfV)))
stop('here')
I got
'data.frame': 800 obs. of 3 variables:
$ key : Factor w/ 8 levels "Y0","Y1","Y2",..: 1 1 1 1 1 1 1 1 1 1 ...
$ ts : Factor w/ 100 levels "1605804700329",..: 100 99 98 97 96 95 94 93 92 91 ...
$ value: Factor w/ 31 levels "2.6398","2.7493",..: 4 2 1 2 2 2 2 2 4 1 ...
https://github.com/DDorch/Rthingsboard/blob/main/R/thingsboard_api.R#L210
dfV$ts <- EpochMilli2Date(dfV$ts, timezone = attributes(startTs)$tzone)
this function, for some reason, takes the factor values instead of the long integers
it happens somehow the same with the resulting value, it is the factor instead of its double value. The result is a nonsense for the ts and value columns of the dataframe.
> df
key ts value
1 Y0 1970-01-01 01:00:00 4
2 Y0 1970-01-01 01:00:00 2
3 Y0 1970-01-01 01:00:00 1
4 Y0 1970-01-01 01:00:00 2
5 Y0 1970-01-01 01:00:00 2
6 Y0 1970-01-01 01:00:00 2
7 Y0 1970-01-01 01:00:00 2
I was not able to reproduce this bug, but anyway I've added a stringsAsFactors = FALSE
argument in the building data.frame instructions. Hope this will definitely solve this issue.
Hi everyone, Trying to reproduce the example from README, I get UNIX starting time and no value as shows the documentation.
Also tried with my thingsboard device and got the same error.
The code I first used is this:
The output is this:
Should I add a previous step to update the date and access the value?