Hello i am having an interesting issue with R
When i do :
touchtimepairs = structure(list(v..length.v.. = structure(c(1543323677.254, 1543323678.137, 1543323679.181, 1543323679.918, 1543323680.729, 1543323681.803, 1543323682.523, 1543323682.977,1543323683.519, 1543323684.454), class = c("POSIXct", "POSIXt"), tzone = "CEST"),v.2.length.v.. = structure(c(1543323678.137, 1543323679.181, 1543323679.918, 1543323680.729, 1543323681.803, 1543323682.523, 1543323682.977, 1543323683.519, 1543323684.454, 1543323690.793), class = c("POSIXct", "POSIXt"), tzone = "CEST")), .Names = c("v..length.v..", "v.2.length.v.."), row.names = c(NA, 10L), class = "data.frame")
data = data.frame(a = seq(1,10), b = seq(21,30), posixtime = touchtimepairs[,1])
for(x in seq(nrow(touchtimepairs))){
a = data$[data$posixtime < touchtimepairs[x,2],]
}
it works without a problem i get results back but when i try to use apply
a = apply(touchtimepairs, 1,
function(x) data[data$posixtime < x[2],])
it does not work anymore, I get an empty data frame. The same happens with the subset() command. Interestingly when i do > instead of < it works !
a = apply(touchtimepairs, 1,
function(x) data[data$posixtime > x[2],])
Then there is another issue:
apply in the case of the > comparison gives another result than the for loop
1951 lines with apply and 1897 with the for loop
can anyone reproduce this behavior?
The posix time has also miliseconds if that is of any interest
Many thanks