I have a dataset called d857 with about 90000 rows of 2 variables. Here is an example of d857:
datetime light
1 2013-05-21 23:10:27 10.220
2 2013-05-21 23:15:27 7.949
3 2013-05-21 23:20:27 5.678
4 2013-05-21 23:25:27 3.407
5 2013-05-21 23:30:27 3.407
I am attempting to perform the twilightCalc function from the Geolight package. When I perform the function I receive the error:
Error in data.frame(id = 1:nrow(smooth), smooth) :
arguments imply differing number of rows: 2, 0
I performed the function on different portions of d857 and have had differing results. The function works on d857[1:27873,]
, but receives error on any portion past that number, but also works on d857[80000:90000,]
. I checked the dataset in its file and do not see any values that are out of the ordinary. What could be causing this error and how could I fix it?
Edit:
Here is d857[27870:27880,] and the sapply function.
> d857[27870:27880,]
datetime light
27870 2013-08-26 17:35:27 1163.944
27871 2013-08-26 17:40:27 1163.944
27872 2013-08-26 17:45:27 1163.944
27873 2013-08-26 17:50:27 1163.944
27874 2013-08-26 17:55:27 1163.944
27875 2013-08-26 18:00:27 1163.944
27876 2013-08-26 18:05:27 1163.944
27877 2013-08-26 18:10:27 1163.944
27878 2013-08-26 18:15:27 1163.944
27879 2013-08-26 18:20:27 1163.944
27880 2013-08-26 18:25:27 1163.944
> sapply(d857$datetime, twilightCalc)
Error in data.frame(datetime = as.POSIXct(as.character(datetime), "UTC"), :
argument "light" is missing, with no default
The solution involves adding two lines of code into R to cut out any dates before the geolocator was active and to log transform the data. After using the function luxTrans on the geolocator data type in the following lines of code before using the twilightCalc function: