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

add_column() and add_row() should throw errors if the input is not a data frame #575

Closed
DavisVaughan opened this issue Feb 9, 2019 · 1 comment
Milestone

Comments

@DavisVaughan
Copy link
Member

@DavisVaughan DavisVaughan commented Feb 9, 2019

tibble::add_column(as.matrix(mtcars), x = 1)
#> [[1]]
#> [1] 21
#> 
#> [[2]]
#> [1] 21
#> 
#> [[3]]
#> [1] 22.8
#> 
#> [[4]]
#> [1] 21.4
#> 
#> [[5]]
#> [1] 18.7
#> 
#> [[6]]
#> [1] 18.1
#> 
#> [[7]]
#> [1] 14.3
#> 
#> [[8]]
#> [1] 24.4
#> 
#> [[9]]
#> [1] 22.8
#> 
#> [[10]]
#> [1] 19.2
#> 
#> [[11]]
#> [1] 17.8
#> 
#> [[12]]
#>  [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

tibble::add_row(as.matrix(mtcars), mpg = 4)
#> Error: New rows in `add_row()` must use columns that already exist:
#> * Can't find column `mpg` in `.data`.
#> Backtrace:
#>     █
#>  1. └─tibble::add_row(as.matrix(mtcars), mpg = 4)

add_row() throws an error, but it might be worth it to make it consistent with one that would be thrown with add_column(). I imagine just checking if .data is a data.frame and throwing an error otherwise.

@krlmlr krlmlr added this to the 2.x.y milestone Feb 22, 2019
@krlmlr krlmlr closed this in a5a20bf Feb 22, 2019
@github-actions
Copy link

@github-actions github-actions bot commented Dec 9, 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.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants