Skip to content

tibble's reference documentation should be updated to explictedly state how to deal with matrices #978

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

Closed
mccroweyclinton-EPA opened this issue Dec 28, 2021 · 3 comments · Fixed by #1012
Milestone

Comments

@mccroweyclinton-EPA
Copy link

library(magrittr)
library(tibble)
cat("Tibble's reference documentation states that it works similarly to
     base::data.frame() but it actually has different behaviour for matrices")
cat ("\n\nCan tibble::tibble() take matries as inputs? Yes it can but the
      resulting tibble is much different than what is expected, here are the
      dimensions of installed.packages() when converted to a tibble using
     tibble()\n")
installed.packages() %>% tibble() %>% dim() %>% cat()

cat("\n\nNotice how the number of dimensions is different than when calling
     base::data.frame()
     \n")
installed.packages() %>% data.frame() %>% dim() %>% cat()

cat("\n\nI think that the correct way to convert maticies to a tibble is by
     using the as_tibble() function but the tibble reference documentation
     (?tibble::tibble) does not mention this. If tibble() behaves differently
     for matrices than base::data.frame() then the tibble reference doc should
     explictedly say so and it should direct users to use as_tibble() instead.
     \n")
installed.packages() %>% as_tibble() %>% dim() %>% cat()
@krlmlr
Copy link
Member

krlmlr commented Dec 28, 2021

Thanks, good point. Would you like to submit a pull request?

Also: What happens if we pass a data frame (named or unnamed) to data.frame() and tibble?

@mccroweyclinton-EPA
Copy link
Author

mccroweyclinton-EPA commented Dec 28, 2021

I have not submitted a Pull Request. The amount of time that it will take to receive approval to submit code to an outside organization would be far to long for such a trivial change.

As far as data.frame -> tibble using the tibble() function, it seems as if the function works as expected.

library(tibble)
library(stringi)

set.seed(10)


tb <- data.frame("Numbers" = 1:10,
                 "Letters" = letters[1:10],
                 "Random" = runif(n=10),
                 "Loreum_Ipsum" = stri_rand_lipsum(n_paragraphs=10, start_lipsum = FALSE),
                 "Sys.time" = Sys.time()
                 )


tb2 <- tibble(tb)
```r

@krlmlr krlmlr added this to the 3.1.7 milestone Dec 29, 2021
krlmlr added a commit that referenced this issue Feb 3, 2022
- Add more examples for data frame and matrix columns (#978, #1012).
@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2023

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.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants