You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've seen tidyverse/dplyr#3630, and I wonder what's the rationale. One advantage I see is that we can support POSIXlt columns (and other related data-frame-like data types). For matrices and data frames, I wonder if as_tibble() could flatten these instead (with a consistent naming scheme) so that the columns remain simple vectors.
With regards to rationale, my use case is for modeling functions like mlm() and mvabund::manyglm() which can take a matrix as the LHS of the model formula to represent a multivariate response; the data argument for those functions ideally has the matrix as a column.
Because I think data frame and matrix columns are an important data structure for reasons that I can't fully articulate yet, but they would be useful in bigrquery (for representing nested, but not repeated, columns) and in data structures for visualisation.
More from #419 that I'm closing now as a duplicate to this. Sorry for the noise:
library(dplyr, warn.conflicts=FALSE)
df<-data.frame(x1= rep(1:3, times=3), x2=1:9)
df$x3<-df %>% mutate(x3=x2)
as_tibble(df)
#> Error: All columns in a tibble must be a 1d vector or a list:#> * Column `x3` is data.frame
Nice. I'll probably need to extract the part that generate the expression for internal use in dplyr, e.g. for what is bound to a symbol in the grouped case.
Hopefully multi dimensional array columns won't be too much of a thing, matrix and data frame columns are already going to require some grasping.
Would it be possible to extend support for matrix columns to mutate()? For example, tibble(a = 1:3, B = matrix(1:6, nrow = 3)) succeeds but tibble(a = 1:3) %>% mutate(B = matrix(1:6, nrow = 3)) fails with error "Error: Column B must be length 3 (the number of rows) or one, not 6". (tibble_2.0.1; dplyr_0.8.0.1).
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.
Activity
krlmlr commentedon Jun 6, 2018
I've seen tidyverse/dplyr#3630, and I wonder what's the rationale. One advantage I see is that we can support
POSIXltcolumns (and other related data-frame-like data types). For matrices and data frames, I wonder ifas_tibble()could flatten these instead (with a consistent naming scheme) so that the columns remain simple vectors.brendanf commentedon Jun 6, 2018
With regards to rationale, my use case is for modeling functions like
mlm()andmvabund::manyglm()which can take a matrix as the LHS of the model formula to represent a multivariate response; thedataargument for those functions ideally has the matrix as a column.hadley commentedon Jun 6, 2018
Because I think data frame and matrix columns are an important data structure for reasons that I can't fully articulate yet, but they would be useful in bigrquery (for representing nested, but not repeated, columns) and in data structures for visualisation.
We absolutely do not want to flatten.
romainfrancois commentedon Jun 8, 2018
More from #419 that I'm closing now as a duplicate to this. Sorry for the noise:
Related to tidyverse/dplyr#3630
Some dplyr code can lead to a tibble with a data frame column and in that case printing and [ is broken:
Better skip message, this is part of #3630,
hadley commentedon Jun 8, 2018
Ok, looks like we'll also need to make some basic fixes to the printing code.
It's not clear to me how a df-col or matrix-col should print, so for now we just need some placeholder that at least doesn't error.
romainfrancois commentedon Jun 8, 2018
It's not just printing,
[also needs some attention:hadley commentedon Jun 8, 2018
Oh got it -
[.tbl_dfwill need to supply additional missing arguments to[.hadley commentedon Jun 8, 2018
Something like this, I think:
romainfrancois commentedon Jun 8, 2018
Nice. I'll probably need to extract the part that generate the expression for internal use in dplyr, e.g. for what is bound to a symbol in the grouped case.
Hopefully multi dimensional array columns won't be too much of a thing, matrix and data frame columns are already going to require some grasping.
hadley commentedon Jun 8, 2018
That's a good point. Rather than being so clever it might be better to do this:
Better skip message, this is part of #3630,
krlmlr commentedon Jun 29, 2018
I have a working implementation locally, will push tomorrow. pillar is ready to handle the printing of these tibbles.
- `tibble()` supports data frame and matrix columns (#416).
Better skip message, this is part of #3630,
Better skip message, this is part of #3630,
Better skip message, this is part of #3630,
bring error msg in line with allowed matrix/df cols as per tidyverse#416
Better skip message, this is part of #3630,
banbh commentedon Apr 2, 2019
Would it be possible to extend support for matrix columns to
mutate()? For example,tibble(a = 1:3, B = matrix(1:6, nrow = 3))succeeds buttibble(a = 1:3) %>% mutate(B = matrix(1:6, nrow = 3))fails with error "Error: ColumnBmust be length 3 (the number of rows) or one, not 6". (tibble_2.0.1; dplyr_0.8.0.1).github-actions commentedon Dec 8, 2020
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.