Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

factor handling in split.data.table, by>1, flatten=F, keep.by=F #1954

Closed
jangorecki opened this issue Dec 6, 2016 · 2 comments
Closed

factor handling in split.data.table, by>1, flatten=F, keep.by=F #1954

jangorecki opened this issue Dec 6, 2016 · 2 comments
Assignees
Milestone

Comments

@jangorecki
Copy link
Member

jangorecki commented Dec 6, 2016

http://stackoverflow.com/questions/40999920/data-table-into-nested-list

## install.packages(c("gapminder", "data.table"))
library(gapminder)
library(data.table)
gapminder <- data.table(gapminder)
my_table <- gapminder[, .(mdl = .(lm(lifeExp ~ pop + gdpPercap, 
                                  data = gapminder))), 
                          by = .(country, continent)]
first_list <- split(my_table, my_table$continent)
second_list <- lapply(first_list, function(x){ 
                   split(x[, country := as.character(country)], x$country)
               })
final_list <- sapply(second_list, function(x) sapply(x, function(y) y$mdl))

split(my_table, by=c("continent", "country"), keep.by = FALSE, flatten = FALSE)
#Error in `[.data.table`(x, i = make.levels(x, cols = "country", sorted = FALSE),  : 
#  Logical error. Type of column should have been checked by now

after convert to character it process fine.

@jangorecki jangorecki added this to the v1.10.2 milestone Dec 6, 2016
@jangorecki jangorecki self-assigned this Dec 6, 2016
@jangorecki
Copy link
Member Author

Issue on hold till #2300 gets resolved.

@jangorecki
Copy link
Member Author

This is already fixed by recent commit 862df78.

@mattdowle mattdowle modified the milestones: Candidate, v1.11.0 May 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants