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

Bug833 asdt list #835

Closed
wants to merge 7 commits into from
Closed

Bug833 asdt list #835

wants to merge 7 commits into from

Conversation

rsaporta
Copy link
Contributor

Addresses issue #833
"as.data.table behavior inconsistent with as.data.frame for matrix list members #833"

Modified / Added:

  • as.data.table.list
  • as.data.table.matrix
  • as.data.table.array (added)

details:

as.data.table.list -- checks if any element has dim, then rest of function splits into two parts (yes/no dim). If an element has dimension, several other tests are performed and eventually returns do.call(cbind, lapply(x, as.data.table)) Additionally, gave user option to use rbind instead of cbind via the argument bind.using. This is useful for list of matrices. For mixed lists, a warning is thrown to inform user that rbind may coerce data types.

as.data.table.matrix -- fixed issue where if keep.rownames=TRUE but x does not have rownames, an error would result. Solution implemented is to use rn=NA_character_. Alternative is to override user and set keep.rownames=FALSE

as.data.tabel.array -- added this function. Goal was to mimic results of as.data.frame.array as closely as possible. One issue remains. Namely, for single-dimension array, as.data.frame preserves dim info. We cannot do that with as.data.table since a column having a dim attribtue will annoy print(x).

@arunsrinivasan
Copy link
Member

@rsaporta I just had a look at this PR.

The fix should address just #833. as.data.table.array should be separate FR, and the fix for as.data.table.matrix should be a separate bug fix.

Tests should be added to tests.Rraw (from my email). And we don't need additional arguments to as.data.table.list. IIUC, isn't the additional logic for as.data.table.list just this:

if (!is.null(unlist(lapply(x, dim))))
    return(eval(as.call(c(expression(data.table), x))))

??

Now I also realise that the output is not identical here as well:

ll = list(1:5, list(6:10, 11:15))
as.data.table(ll)
as.data.frame(ll)

@mattdowle any thoughts?

@arunsrinivasan arunsrinivasan deleted the BUG833_asdt_list branch August 14, 2015 08:21
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

Successfully merging this pull request may close these issues.

2 participants