Is the new invariants article set in stone or would be possible to make a documentation request?
# Create a data frame of y response and x1 predictor# with intentionally unusually naming due to inherited data issue.y.variable<- as.factor(c("false_318","false_318","false_318","true_130","true_130"))
# Gives Error: `i` must have one dimension, not 2.
This error will product the error "Error: i must have one dimension, not 2." However, by simply playing around a bit I figured out a work around.
I am not strong it R, but for me it seemed a named vector [n,1] and ""matrix"" (really a vector) that is nx1 (n rows and 1 column) was the reason for the error. I researched more into this error and came across this page (https://github.com/tidyverse/tibble/blob/master/NEWS.md) and this:
Subset assignment ("subassignment") and also subsetting has become stricter. Symptoms:
**i must have one dimension, not 2**
The "invariants" article at https://tibble.tidyverse.org/dev/articles/invariants.html describes the invariants that the operations follow in tibble, and the most important differences to data frames. We tried to make subsetting and subassignment as safe as possible, so that errors are caught early on, while introducing as little friction as possible.
This made it clear that there are probably very good reasons that a named vector or a literal [nx1] area can no longer be passed into a list. However, I was hoping the documentation could include more examples so its a bit more clear to new users.
Thank you for your time,
The text was updated successfully, but these errors were encountered:
@krlmlr I am very sorry. My internet crashed around the time I tried to posting this, so I didn't think it posted. I have updated it.
(P.S. If it would be relevant to any tags, I would appreciate it. 👍 )
partition<- as.matrix(data.frame(Resample= c(1, 2, 3, 4)))
# Create a data frame of y response and x1 predictor# with intentionally unusually naming due to inherited data issue.y.variable<- as.factor(c("false_318", "false_318", "false_318", "true_130", "true_130"))
x1<- c(3225067, 6907531, 6911683, 6991870, 2222)
mydata<- tibble(y.variable=y.variable, x1=x1)
#> Warning: The `i` argument of ``[`()` can't be a matrix as of tibble 3.0.0.#> Convert to a vector.#> This warning is displayed once every 8 hours.#> Call `lifecycle::last_warnings()` to see where this warning was generated.#> # A tibble: 4 x 2#> y.variable x1#> <fct> <dbl>#> 1 false_318 3225067#> 2 false_318 6907531#> 3 false_318 6911683#> 4 true_130 6991870
- `[<-.tbl_df()` coerces matrices to data frames (#762).
- Use delayed import for cli to work around unload problems in downstream packages (#754).
- More soft-deprecation warnings are actually visible.
- If `.name_repair` is a function, no repair messages are shown (#763).
- Remove superseded signal for `as_tibble.list()`, because `as_tibble_row()` only works for size 1.
- `as_tibble(validate = )` now always triggers a deprecation warning.
- Subsetting and subassignment of rows with one-column matrices work again, with a deprecation warning (#760).
- Attempts to update a tibble row with an atomic vector give a clearer error message. Recycling message for subassignment appears only if target size is != 1.
- Tweak title of "Invariants" vignette.