[datatable-help] Change in list( ) behavior inside join
Shir Levkowitz
levkowitz at dc-energy.com
Tue Mar 25 14:51:45 CET 2014
Sorry about that! dt.classEx should just be dt.hrEx… Full corrected example below. Also you are correct 3.0.2 is the R version, not 3.2.0.
Shir
-----
library(data.table)
# dates
dt.dateEx <- data.table(date = as.character(seq(as.Date('2014-04-01'), as.Date('2014-04-15'), by = 1)))
setkey(dt.dateEx, date)
# hours
dt.hrEx <- copy(dt.dateEx)
dt.hrEx <- dt.hrEx[, list(hour_beginning =0:23), by = list(dt = date)] # rep x24 per date
setkey(dt.hrEx, dt, hour_beginning)
# as expected
dt.hrEx[dt.dateEx][, list(dt, hour_beginning)]
# not expected outcome
dt.hrEx[dt.dateEx, list(hour_beginning)]
On Mar 25, 2014, at 9:45 AM, Matt Dowle <mdowle at mdowle.plus.com> wrote:
>
> Shir is using v1.9.2 though, although in R 3.2.0 apparently which might mean R 3.0.2 perhaps.
> Anyway regardless of versions, the example code results in errors. Shir?
>
> > # dates
> > dt.dateEx <- data.table(date = as.character(seq(as.Date('2014-04-01'), as.Date('2014-04-15'), by = 1)))
> > setkey(dt.dateEx, date)
> >
> > # hours
> > dt.hrEx <- copy(dt.dateEx)
> > dt.hrEx <- dt.hrEx[, list(hour_beginning =0:23), by = list(dt = date)] # rep x24 per date
> > setkey(dt.hrEx, dt, hour_beginning)
> >
> > # as expected
> > dt.classEx[dt.dateEx][, list(dt, hour_beginning)]
> Error: object 'dt.classEx' not found
> >
> > # not expected outcome
> > dt.classEx[dt.dateEx, list(hour_beginning)]
> Error: object 'dt.classEx' not found
> >
>
>
>
>
> On 24/03/14 19:57, Eduard Antonyan wrote:
>> You're probably expecting the by-without-by behavior - see this post: http://r.789695.n4.nabble.com/by-EACHI-and-related-please-check-ok-td4686732.html and follow the links within for more detail.
>>
>>
>> On Mon, Mar 24, 2014 at 2:37 PM, Shir Levkowitz <levkowitz at dc-energy.com> wrote:
>> It looks like the latest version of data.table has changed the behavior of list( ) inside of a join - is this behavior as expected? Has anyone reported or encountered this change? It seems like a bug to me. I am using data.table v1.9.2 in R 3.2.0 .
>>
>> Thanks,
>> Shir Levkowitz
>>
>>
>>
>>
>>
>> #-----------------------------------------------
>>
>>
>> library(data.table)
>>
>> # dates
>> dt.dateEx <- data.table(date = as.character(seq(as.Date('2014-04-01'), as.Date('2014-04-15'), by = 1)))
>> setkey(dt.dateEx, date)
>>
>> # hours
>> dt.hrEx <- copy(dt.dateEx)
>> dt.hrEx <- dt.hrEx[, list(hour_beginning =0:23), by = list(dt = date)] # rep x24 per date
>> setkey(dt.hrEx, dt, hour_beginning)
>>
>> # as expected
>> dt.classEx[dt.dateEx][, list(dt, hour_beginning)]
>>
>> # not expected outcome
>> dt.classEx[dt.dateEx, list(hour_beginning)]
>>
>> _______________________________________________
>> datatable-help mailing list
>> datatable-help at lists.r-forge.r-project.org
>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
>>
>>
>>
>> _______________________________________________
>> datatable-help mailing list
>> datatable-help at lists.r-forge.r-project.org
>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20140325/e5ba243e/attachment.html>
More information about the datatable-help
mailing list