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

as.data.table() returns a 1 column matrix when the matrix columns are factors #868

Closed
mgahan opened this issue Oct 8, 2014 · 1 comment
Assignees
Milestone

Comments

@mgahan
Copy link

mgahan commented Oct 8, 2014

Here is some sample data
iris <- data.table(iris)

This code produces a one column vector when Species is a factor.
as.data.table(combn(unique(iris$Species),2))

V1
1: setosa
2: versicolor
3: setosa
4: virginica
5: versicolor
6: virginica

While this code produces a matrix.
as.data.table(combn(unique(as.character(iris$Species)),2))

V1 V2 V3
1: setosa setosa versicolor
2: versicolor virginica virginica

Issue found through SO question here:
http://stackoverflow.com/questions/26244685/r-count-every-possible-pair-of-values-in-a-column-grouped-by-multiple-columns/26246588?noredirect=1#comment41177317_26246588

@arunsrinivasan
Copy link
Member

@mgahan 👍 thank you.

@arunsrinivasan arunsrinivasan self-assigned this Feb 8, 2015
@arunsrinivasan arunsrinivasan added this to the v1.9.6 milestone Feb 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants