Rui Barradas wrote
Sorry, but the output of dput() starts with 'structure', not like what
you've posted.
And there are much more than 20 dates in the beginning.
The posting guide is easy to find
apologies for my earlier ignorance.
It seems the output of dput(head(data, 20) is too big to print in full. When
I press stop immediately after pressing enter, I get:
dput(head(long, 30))
structure(list(tripID = c(3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L), device_info_serial = c(121L, 121L, 121L,
121L, 121L, 121L, 121L, 121L, 121L, 121L, 121L, 121L, 121L, 121L,
121L, 121L, 121L, 121L, 121L, 121L, 121L, 121L, 121L, 121L, 121L,
121L, 121L, 121L, 121L, 121L), mdate = structure(c(33L, 33L,
33L, 33L, 33L, 33L, 33L, 33L, 33L, 33L, 33L, 33L, 33L, 33L, 33L,
If I let it run just a little bit longer, it gives the enormous output like
before.
I made a new vector containing only the columns I need for this problem:
str(dat)
List of 4
$ device_info_serial: int [1:34773] 121 121 121 121 121 121 121 121 121 121
...
$ hour : int [1:34773] 10 11 11 11 11 11 11 11 11 11 ...
$ time : POSIXlt[1:34773], format: "2009-05-21 10:59:24" ...
$ tripID : int [1:34773] 3 3 3 3 3 3 3 3 3 3 ...
You were right about the factors. I think I solved it using:
dat$time<- strptime(long$date_time.x, format = "%Y-%m-%d %H:%M:%S")
this seems to help, as R doesn't start computing for hours. It does give an
error though:
departures<- lapply(split(dat, list(dat$device_info_serial, dat$tripID)),
function(x) x[x$time == min(x$time),])
Error in x[x$time == min(x$time), ] : incorrect number of dimensions
In addition: Warning messages:
1: In split.default(dat, list(dat$device_info_serial, dat$tripID)) :
data length is not a multiple of split variable
2: In min(x$time) : no non-missing arguments to min; returning Inf
--
View this message in context:
http://r.789695.n4.nabble.com/noob-requesting-help-tp4632803p4633317.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.