r data.table sequence dates -


i having question sequencing dates in data.table group.

i have code use work in past not working.

i have figured out issue having newer version of data.table package.

the code worked on older version (1.8.x) , updated 1.9.2 , code isn't working.

can me figure out.

here data:

test_data <- data.frame(group=c(1,2,3),                     date=c("2011-01-01","2012-02-02","2013-03-03"),                     date2=sys.date(),                     stringsasfactors=false) test_data[,"date"] <- as.date(test_data[,"date"]) test_data[,"date2"] <- as.date(test_data[,"date2"]) 

here code"

library("data.table")  identifier <- "group"  results <- data.table(test_data)[,{s=seq(from=date,to=sys.date(),by="days")},                              by=list(group,date)] 

i getting following error:

error in ops.date(del, by) : / not defined "date" objects

thanks ahead of time!

looks date column being coerced numeric can see with

data.table(test_data)[, date, by=list(group,date)] #   group       date  date #1:     1 2011-01-01 14975 #2:     2 2012-02-02 15372 #3:     3 2013-03-03 15767 

i think it's regression since worked older versions of data.table, can work around coercing date.

data.table(test_data)[, seq(as.date(date, origin="1970-01-01"), sys.date(), by="days"),                       by=list(group,date)] 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -