[datatable-help] Change in list( ) behavior inside join
Matt Dowle
mdowle at mdowle.plus.com
Tue Mar 25 15:04:11 CET 2014
Thanks, now runs. That is a bug in v1.9.2 which is fixed in v1.9.3 (I
ran it to check), from NEWS :
o When joining to fewer columns than the key has, using one of the
later key columns
explicitly in j repeated the first value. A problem introduced by
v1.9.2 and not
caught by our 1,220 tests, or tests in 37 dependent packages. Test
added. Many
thanks to Michele Carriero for reporting.
DT = data.table(a=1:2, b=letters[1:6], key="a,b") # keyed by
a and b
DT[.(1), list(b,...)] # correct result again (joining just to
a not b but using b)
Matt
On 25/03/14 13:51, Shir Levkowitz wrote:
> 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
> <mailto: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 <mailto: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
>>> <mailto: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/cfc40738/attachment-0001.html>
More information about the datatable-help
mailing list