Most likely, this 
(https://r-forge.r-project.org/tracker/index.php?func=detail&aid=4882&group_id=240&atid=5335),
 when fixed, will take care of it? 

Arun


On Wednesday, September 11, 2013 at 11:17 AM, Chris Neff wrote:

> Indeed, it shows that k1 and k2 both have names of length 2, and both times 
> the value of names is just the variable names.
> 
> Where the names are getting added is by apply.  What the issue with 
> data.table is that it does not ignore names from short variables. I now have 
> a small reproducible example I can share: 
> 
> d <- data.frame(x=1:5)
> 
> f <- function(x) {data.table(x=x, y=1:10)}
> 
> l <- apply(d, 1, f)
> 
> lapply(l, function(x) lapply(x, names)) # All values of x have a name 
> 
> a <- rbindlist(l) # a$x will segfault after this
> 
> 
> The underlying issue is what data.table and data.frame do with rownames and 
> recycling. Look at this simple case: 
> 
> x <- 1:5
> names(x) <- letters[1:5]
> 
> df <- data.frame(x=x, y=1:10) 
> #Warning message:
> #  In data.frame(x = x, y = 1:10) :
> #  row names were found from a short variable and have been discarded
> 
> lapply(df, names) # no names
> 
> dt <- data.table(x=x, y=1:1) # No warning
> 
> lapply(dt, names) # x has names, and they get recycled.
> 
> 
> So data.table needs to follow data.frame logic for discarding row names when 
> they would otherwise be recycled. 
> 
> 
> Bug submitted here: 
> https://r-forge.r-project.org/tracker/index.php?func=detail&aid=4890&group_id=240&atid=975
 
(https://r-forge.r-project.org/tracker/index.php?func=detail&aid=4890&group_id=240&atid=975)>
 
> I'm surprised this has never arisen before, it seems like something that has 
> been around forever.
> 
> 
> _______________________________________________
> datatable-help mailing list
> [email protected] 
> (mailto:[email protected])
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
> 
> 


_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help

Reply via email to