-
Notifications
You must be signed in to change notification settings - Fork 131
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_tibble.matrix should keep rownames attribute #288
Comments
Looks like this conversion is done in C-land with That's a bit outside my skills, but I can try re-setting the attribute after the conversion, inside |
Thanks. I agree that there is some inconsistency, but I'd rather not support row names in tibbles altogether. We may want to give a warning at some point, so there seems to be no point in enabling this functionality now. We may want to consider adding a |
@krlmlr I think the key idea is really interesting, and something I've definitely missed from data.table, so it's exciting to see work in that direction. I agree that tibble shouldn't support rownames, but I think it's important to make it easy for users to work with data that has rownames through no fault of theirs. That's why I made the PR, to make it as easy to get matrix rownames into a column as it is for data.frames. Even better might be to have the as_tibble methods for matrix/data.frames accept a "rownames" argument, which will do what |
If that wouldn't be handled best with new keys functionality, I'd be happy to write up a PR to modify |
|
- In `glimpse()`, compute `type_sum()` from data frame for dbplyr compatibility (#328). - `as_tibble.matrix()` repairs column names. - Compatible with R 3.1 (#323). - Make add_case() and alias for add_row() (#324, @LaDilettante). - `add_column()` to an empty zero-row tibble with a variable of nonzero length now produces a correct error message (#319). - Logical indexes are supported, a warning is raised if the length does not match the number of rows or 1 (#318). - Tibbles now support character subsetting (#312). - `as_tibble()` gains `rownames` argument (#288, #289). - Remove Rcpp dependency (#313, @patperry). - ``` `[.tbl_df`() ``` supports `drop = TRUE` and omits the warning if `j` is passed. The calls `df[i, j, drop = TRUE]` and `df[i, drop = TRUE]` are now compatible with data frames again (#307, #311). - Prevent `add_column()` from dropping classes and attributes by removing the use of `cbind()`. Additionally this ensures that `add_column()` can be used with grouped data frames (#303, @DavisVaughan). - Fixed width for word wrapping of the extra information (#301).
New formatting -------------- The new pillar package is now responsible for formatting tibbles. Pillar will try to display as many columns as possible, if necessary truncating or shortening the output. Colored output highlights important information and guides the eye. The vignette in the tibble package describes how to adapt custom data types for optimal display in a tibble. New features ------------ - Make `add_case()` an alias for `add_row()` (#324, @LaDilettante). - `as_tibble()` gains `rownames` argument (#288, #289). - `as_tibble.matrix()` repairs column names. - Tibbles now support character subsetting (#312). - ``` `[.tbl_df`() ``` supports `drop = TRUE` and omits the warning if `j` is passed. The calls `df[i, j, drop = TRUE]` and `df[i, drop = TRUE]` are now compatible with data frames again (#307, #311). Bug fixes --------- - Improved compatibility with remote data sources for `glimpse()` (#328). - Logical indexes are supported, a warning is raised if the length does not match the number of rows or 1 (#318). - Fixed width for word wrapping of the extra information (#301). - Prevent `add_column()` from dropping classes and attributes by removing the use of `cbind()`. Additionally this ensures that `add_column()` can be used with grouped data frames (#303, @DavisVaughan). - `add_column()` to an empty zero-row tibble with a variable of nonzero length now produces a correct error message (#319). Internal changes ---------------- - Reexporting `has_name()` from rlang, instead of forwarding, to avoid warning when importing both rlang and tibble. - Compatible with R 3.1 (#323). - Remove Rcpp dependency (#313, @patperry).
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. |
Currently,
as_tibble.matrix()
throws away rownames:This is inconsistent with
as_tibble.data.frame
, which makes sure to keep rownamesIf a user has a rownamed matrix and wants a tibble with those rownames in it (e.g. confusion matrices from the
randomForest
package), they have to convert to a base data.frame firstFixing this bug would remove the need for the
as.data.frame()
call, and make the steps match those for doing the same with a data.frame, e.g.This only saves one step, but standardizing the tibble interface across matrices and data.frames where possible seems like a worthy UX improvement.
Session Info
Used newest github version to make sure this wasn't fixed already
The text was updated successfully, but these errors were encountered: