Rui Barradas wrote > > It's stringsAsFactors = FALSE, just one '='. > > sapply(dat, length) > > It should return 4 times the value 34773. > > use dput() >
it worked! > dat2 <- data.frame(dat, stringsAsFactors = FALSE) > sapply(dat2, length) device_info_serial hour time 34773 34773 34773 tripID 34773 > dput(head(dat2, 20)) structure(list(device_info_serial = c(121L, 121L, 121L, 121L, 121L, 121L, 121L, 121L, 121L, 121L, 121L, 121L, 121L, 121L, 121L, 121L, 121L, 121L, 121L, 121L), hour = c(10L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 13L), time = structure(c(1242896364, 1242896671, 1242897111, 1242897399, 1242897686, 1242897978, 1242898281, 1242898589, 1242898916, 1242899253, 1242899542, 1242899835, 1242901122, 1242901902, 1242902199, 1242902489, 1242902807, 1242903096, 1242903402, 1242903708), class = c("POSIXct", "POSIXt"), tzone = ""), tripID = c(3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L)), .Names = c("device_info_serial", "hour", "time", "tripID"), row.names = c(NA, 20L), class = "data.frame") > > departures <- lapply(split(dat2, list(dat2$device_info_serial, > dat2$tripID)), function(x) x[x$time == min(x$time),]) Now I have a new problem: I need to make a histogram of the hours (in this case, their time of departure), for the whole population and for each bird seperately. Before, I used this: hist(active$hour, breaks = 24, xlim=c(0,24)) and: b121 <- active[which(active$device_info_serial == 121),] b130 <- active[which(active$device_info_serial == 130),] b132 <- active[which(active$device_info_serial == 132),] b133 <- active[which(active$device_info_serial == 133),] etc. But now there are no departures$device_info_serial or departures$hour, because departures is a list, not a data frame. I've tried: > dep <- data.frame(departures, stringsAsFactors = FALSE) Error in data.frame(`121.1` = list(device_info_serial = integer(0), hour = integer(0), : arguments imply differing number of rows: 0, 1, 2 > dep <- data.frame(departures) Error in data.frame(`121.1` = list(device_info_serial = integer(0), hour = integer(0), : arguments imply differing number of rows: 0, 1, 2 -- View this message in context: http://r.789695.n4.nabble.com/noob-requesting-help-tp4632803p4633637.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.