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

Use num_as_location(oob = "extend") internally #746

Closed
krlmlr opened this issue Mar 25, 2020 · 6 comments · Fixed by #795
Closed

Use num_as_location(oob = "extend") internally #746

krlmlr opened this issue Mar 25, 2020 · 6 comments · Fixed by #795
Labels
feature a feature request or enhancement subsetting 🍽 vctrs ↗️ Requires vctrs package
Milestone

Comments

@krlmlr
Copy link
Member

krlmlr commented Mar 25, 2020

for subassignment.

@lionel-: Is this a good idea for tibble 3.0.0?

@lionel-
Copy link
Member

lionel- commented Mar 25, 2020

I think so. I implemented this for tibble :)

@krlmlr
Copy link
Member Author

krlmlr commented Mar 25, 2020

Do we want to support the oob argument for vec_as_location() too, for character input? This would then fill OOB values with indices.

Would it be too bad if vec_as_location() returned a named vector for character input?

@lionel-
Copy link
Member

lionel- commented Mar 25, 2020

Do we want to support the oob argument for vec_as_location() too, for character input? This would then fill OOB values with indices.

Can you show an example please?

Would it be too bad if vec_as_location() returned a named vector for character input?

This isn't possible because we preserve the names of the subscript vector.

@krlmlr
Copy link
Member Author

krlmlr commented Mar 26, 2020

Works already

i <- c(1, 2, 4, 3)
i <- rlang::set_names(i, letters[i])
i
#> a b d c 
#> 1 2 4 3
vctrs::num_as_location(i, 3, oob = "extend")
#> a b d c 
#> 1 2 4 3

Desired behavior

i <- c(1, 2, 4, 3)
i <- rlang::set_names(letters[i])
i
#>   a   b   d   c 
#> "a" "b" "d" "c"
vctrs::vec_as_location(i, 3, letters[1:3], oob = "extend")
#> a b d c 
#> 1 2 4 3

Created on 2020-03-26 by the reprex package (v0.3.0)

@hadley hadley added feature a feature request or enhancement subsetting 🍽 vctrs ↗️ Requires vctrs package labels Jun 5, 2020
@krlmlr
Copy link
Member Author

krlmlr commented Jun 25, 2020

Requires r-lib/vctrs#1166.

@krlmlr krlmlr added this to the 3.1.0 milestone Jul 4, 2020
krlmlr added a commit that referenced this issue Oct 2, 2020
- Use `vctrs::num_as_location()` internally for subset assignment of rows and columns for better error messages (#746).
krlmlr added a commit that referenced this issue Feb 25, 2021
tibble 3.0.4

- Establish compatibility with upcoming pillar 1.5.0 (#818).

- `tbl_sum()` shows "data frame" instead of "tibble" for objects inheriting from `"tbl"` but not `"tbl_df"` (#818).

- Export `format.tbl()` and `print.tbl()` only if pillar doesn't (#816).

- Use `vctrs::num_as_location()` internally for subset assignment of rows and columns for better error messages (#746).

- Adapt tests to the development version of testthat.

- Fix documentation link to `base::Extract`.

- `add_row(df)` adds an empty row again (#809, @DavisVaughan).
@github-actions
Copy link
Contributor

github-actions bot commented Oct 3, 2021

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 Oct 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature a feature request or enhancement subsetting 🍽 vctrs ↗️ Requires vctrs package
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants