From 16e51738ebe9ae5ff79fde4068e52c286ec21aad Mon Sep 17 00:00:00 2001 From: krlmlr Date: Mon, 20 Feb 2023 09:54:07 +0000 Subject: [PATCH] [create-pull-request] automated change --- .../_snaps/vignette-invariants/invariants.md | 1295 ++++++++--------- 1 file changed, 598 insertions(+), 697 deletions(-) diff --git a/tests/testthat/_snaps/vignette-invariants/invariants.md b/tests/testthat/_snaps/vignette-invariants/invariants.md index e64785adf..379e79a4f 100644 --- a/tests/testthat/_snaps/vignette-invariants/invariants.md +++ b/tests/testthat/_snaps/vignette-invariants/invariants.md @@ -69,14 +69,12 @@ new_df() ```r -new_tbl() -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 e -#> 2 NA f -#> 3 3 g -#> 4 NA h +new_df() +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -138,6 +136,8 @@ new_tbl() + + For subset assignment (subassignment, for short), we need a fresh copy of the data for each test. The `with_*()` functions (omitted here for brevity) allow for a more concise notation. These functions take an assignment expression, execute it on a fresh copy of the data, and return the data for printing. @@ -164,19 +164,17 @@ with_df(df$n <- rev(df$n), verbose = TRUE) ```r -with_tbl(tbl$n <- rev(tbl$n), verbose = TRUE) +with_df(tbl$n <- rev(tbl$n), verbose = TRUE) #> { -#> tbl <- new_tbl() +#> df <- new_df() #> tbl$n <- rev(tbl$n) -#> tbl +#> df #> } -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 NA e -#> 2 3 f -#> 3 NA g -#> 4 1 h +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -228,7 +226,7 @@ identical(df[[3]], .subset2(df, 3)) ```r -identical(tbl[[3]], .subset2(tbl, 3)) +identical(tbl[[3]], .subset2(df, 3)) #> [1] TRUE ``` @@ -242,7 +240,7 @@ identical(df2[["df"]], .subset2(df2, "df")) ```r -identical(tbl2[["tbl"]], .subset2(tbl2, "tbl")) +identical(tbl2[["df"]], .subset2(df2, "df")) #> [1] TRUE ``` @@ -493,7 +491,7 @@ tbl[[Inf]] -Character OOB access is silent because a common package idiom is to check for the absence of a column with `is.null(df[[var]])`. +Character OOB access is silent because a common package idiom is to check for the absence of a column with `is.null(tbl[[var]])`.
@@ -583,8 +581,8 @@ identical(df2$tb, df2[["tb"]]) ```r -identical(tbl2$tb, tbl2[["tb"]]) -#> [1] TRUE +identical(df2$tb, tbl2[["tb"]]) +#> [1] FALSE ```
@@ -597,14 +595,14 @@ identical(df2$m, df2[["m"]]) ```r -identical(tbl2$m, tbl2[["m"]]) +identical(df2$m, tbl2[["m"]]) #> [1] TRUE ```
Unlike data frames, tibbles do not partially match names. -Because `df$x` is rarely used in packages, it can raise a warning: +Because `tbl$x` is rarely used in packages, it can raise a warning:
@@ -717,7 +715,7 @@ tbl[c(1, 1)] For tibbles with repeated column names, subsetting by name uses the first matching column. -`nrow(df[j])` equals `nrow(df)`. +`nrow(tbl[j])` equals `nrow(df)`.
@@ -751,7 +749,7 @@ df[is.na(df)] ```r -tbl[is.na(tbl)] +tbl[is.na(df)] #> [1] NA NA ``` @@ -793,7 +791,7 @@ df[!is.na(df)] ```r -tbl[!is.na(tbl)] +tbl[!is.na(df)] #> Error in `vec_c()`: #> ! Can't combine `n` and `c` . ``` @@ -1281,9 +1279,10 @@ A more efficient implementation of `x[[i, j]]` would check that `j` is a scalar ```r -df[[1, 1]] +tbl[[1, 1]] #> [1] 1 -df[[1, 3]] +tbl[[1, 3]] +#> [[1]] #> [1] 9 ``` @@ -1312,14 +1311,12 @@ with_df(df[[1]] <- 0) ```r -with_tbl(tbl[[1]] <- 0) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 0 e -#> 2 0 f -#> 3 0 g -#> 4 0 h +with_df(tbl[[1]] <- 0) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ```
@@ -1336,14 +1333,12 @@ with_df(df[[3]] <- 4:1) ```r -with_tbl(tbl[[3]] <- 4:1) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 e 4 -#> 2 NA f 3 -#> 3 3 g 2 -#> 4 NA h 1 +with_df(tbl[[3]] <- 4:1) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ```
@@ -1360,14 +1355,17 @@ with_df2(df2[[1]] <- 0) ```r -with_tbl2(tbl2[[1]] <- 0) -#> # A tibble: 4 x 2 -#> tb m[,1] [,2] [,3] [,4] -#> -#> 1 0 1 0 0 0 -#> 2 0 0 1 0 0 -#> 3 0 0 0 1 0 -#> 4 0 0 0 0 1 +with_df2(tbl2[[1]] <- 0) +#> tb.n tb.c tb.li m.1 m.2 m.3 +#> 1 1 e 9 1 0 0 +#> 2 NA f 10, 11 0 1 0 +#> 3 3 g 12, 13, 14 0 0 1 +#> 4 NA h text 0 0 0 +#> m.4 +#> 1 0 +#> 2 0 +#> 3 0 +#> 4 1 ```
@@ -1384,14 +1382,17 @@ with_df2(df2[[2]] <- 4:1) ```r -with_tbl2(tbl2[[2]] <- 4:1) -#> # A tibble: 4 x 2 -#> tb$n $c $li m -#> -#> 1 1 e 4 -#> 2 NA f 3 -#> 3 3 g 2 -#> 4 NA h 1 +with_df2(tbl2[[2]] <- 4:1) +#> tb.n tb.c tb.li m.1 m.2 m.3 +#> 1 1 e 9 1 0 0 +#> 2 NA f 10, 11 0 1 0 +#> 3 3 g 12, 13, 14 0 0 1 +#> 4 NA h text 0 0 0 +#> m.4 +#> 1 0 +#> 2 0 +#> 3 0 +#> 4 1 ```
@@ -1410,14 +1411,12 @@ with_df(df[[1]] <- 0)
```r -with_tbl(tbl[[1]] <- 0) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 0 e -#> 2 0 f -#> 3 0 g -#> 4 0 h +with_df(tbl[[1]] <- 0) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ```
@@ -1434,14 +1433,12 @@ with_df(df[["c"]] <- 0) ```r -with_tbl(tbl[["c"]] <- 0) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 0 -#> 2 NA 0 -#> 3 3 0 -#> 4 NA 0 +with_df(tbl[["c"]] <- 0) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ```
@@ -1460,7 +1457,7 @@ with_df(df[[TRUE]] <- 0) ```r -with_tbl(tbl[[TRUE]] <- 0) +with_df(tbl[[TRUE]] <- 0) #> Error in `[[<-`: #> ! Can't assign column with `TRUE`. #> x `TRUE` must be numeric or character, not `TRUE`. @@ -1476,7 +1473,7 @@ with_df(df[[1:3]] <- 0) ```r -with_tbl(tbl[[1:3]] <- 0) +with_df(tbl[[1:3]] <- 0) #> Error in `[[<-`: #> ! Can't assign column with `1:3`. #> x Subscript `1:3` must be size 1, not 3. @@ -1492,7 +1489,7 @@ with_df(df[[c("n", "c")]] <- 0) ```r -with_tbl(tbl[[c("n", "c")]] <- 0) +with_df(tbl[[c("n", "c")]] <- 0) #> Error in `[[<-`: #> ! Can't assign column with `c("n", "c")`. #> x Subscript `c("n", "c")` must be size 1, not 2. @@ -1508,7 +1505,7 @@ with_df(df[[FALSE]] <- 0) ```r -with_tbl(tbl[[FALSE]] <- 0) +with_df(tbl[[FALSE]] <- 0) #> Error in `[[<-`: #> ! Can't assign column with `FALSE`. #> x `FALSE` must be numeric or character, not `FALSE`. @@ -1524,7 +1521,7 @@ with_df(df[[1:2]] <- 0) ```r -with_tbl(tbl[[1:2]] <- 0) +with_df(tbl[[1:2]] <- 0) #> Error in `[[<-`: #> ! Can't assign column with `1:2`. #> x Subscript `1:2` must be size 1, not 2. @@ -1540,7 +1537,7 @@ with_df(df[[NA_integer_]] <- 0) ```r -with_tbl(tbl[[NA_integer_]] <- 0) +with_df(tbl[[NA_integer_]] <- 0) #> Error in `[[<-`: #> ! Can't assign column with `NA_integer_`. #> x Subscript `NA_integer_` must be a location, not an integer `NA`. @@ -1556,7 +1553,7 @@ with_df(df[[NA]] <- 0) ```r -with_tbl(tbl[[NA]] <- 0) +with_df(tbl[[NA]] <- 0) #> Error in `[[<-`: #> ! Can't assign column with `NA`. #> x Subscript `NA` must be a location, not an integer `NA`. @@ -1572,7 +1569,7 @@ with_df(df[[NA_character_]] <- 0) ```r -with_tbl(tbl[[NA_character_]] <- 0) +with_df(tbl[[NA_character_]] <- 0) #> Error in `[[<-`: #> ! Can't assign column with `NA_character_`. #> x Subscript `NA_character_` must be a location, not a character `NA`. @@ -1598,14 +1595,12 @@ with_df(df[["li"]] <- list(0)) ```r -with_tbl(tbl[["li"]] <- list(0)) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 e -#> 2 NA f -#> 3 3 g -#> 4 NA h +with_df(tbl[["li"]] <- list(0)) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -1618,16 +1613,17 @@ with_df2(df2[["tb"]] <- df[1, ]) ```r -with_tbl2(tbl2[["tb"]] <- tbl[1, ]) -#> # A tibble: 4 x 2 -#> tb$n $c $li m[,1] [,2] -#> -#> 1 1 e 1 0 -#> 2 1 e 0 1 -#> 3 1 e 0 0 -#> 4 1 e 0 0 -#> # ... with 1 more variable: -#> # m[3:4] +with_df2(tbl2[["tb"]] <- tbl[1, ]) +#> tb.n tb.c tb.li m.1 m.2 m.3 +#> 1 1 e 9 1 0 0 +#> 2 NA f 10, 11 0 1 0 +#> 3 3 g 12, 13, 14 0 0 1 +#> 4 NA h text 0 0 0 +#> m.4 +#> 1 0 +#> 2 0 +#> 3 0 +#> 4 1 ``` @@ -1640,16 +1636,17 @@ with_df2(df2[["m"]] <- df2[["m"]][1, , drop = FALSE]) ```r -with_tbl2(tbl2[["m"]] <- tbl2[["m"]][1, , drop = FALSE]) -#> # A tibble: 4 x 2 -#> tb$n $c $li m[,1] [,2] -#> -#> 1 1 e 1 0 -#> 2 NA f 1 0 -#> 3 3 g 1 0 -#> 4 NA h 1 0 -#> # ... with 1 more variable: -#> # m[3:4] +with_df2(tbl2[["m"]] <- tbl2[["m"]][1, , drop = FALSE]) +#> tb.n tb.c tb.li m.1 m.2 m.3 +#> 1 1 e 9 1 0 0 +#> 2 NA f 10, 11 0 1 0 +#> 3 3 g 12, 13, 14 0 0 1 +#> 4 NA h text 0 0 0 +#> m.4 +#> 1 0 +#> 2 0 +#> 3 0 +#> 4 1 ``` @@ -1668,14 +1665,12 @@ with_df(df[[1]] <- 1) ```r -with_tbl(tbl[[1]] <- 1) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 e -#> 2 1 f -#> 3 1 g -#> 4 1 h +with_df(tbl[[1]] <- 1) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -1692,14 +1687,12 @@ with_df(df[[1]] <- 4:1) ```r -with_tbl(tbl[[1]] <- 4:1) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 4 e -#> 2 3 f -#> 3 2 g -#> 4 1 h +with_df(tbl[[1]] <- 4:1) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -1712,7 +1705,7 @@ with_df(df[[1]] <- 3:1) ```r -with_tbl(tbl[[1]] <- 3:1) +with_df(tbl[[1]] <- 3:1) #> Error in `[[<-`: #> ! Assigned data `3:1` must be compatible with existing data. #> x Existing data has 4 rows. @@ -1736,7 +1729,7 @@ with_df(df[[1]] <- 2:1) ```r -with_tbl(tbl[[1]] <- 2:1) +with_df(tbl[[1]] <- 2:1) #> Error in `[[<-`: #> ! Assigned data `2:1` must be compatible with existing data. #> x Existing data has 4 rows. @@ -1765,14 +1758,12 @@ with_df(df[["x"]] <- 0) ```r -with_tbl(tbl[["x"]] <- 0) -#> # A tibble: 4 x 4 -#> n c li x -#> -#> 1 1 e 0 -#> 2 NA f 0 -#> 3 3 g 0 -#> 4 NA h 0 +with_df(tbl[["x"]] <- 0) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -1789,14 +1780,12 @@ with_df(df[[4]] <- 0) ```r -with_tbl(tbl[[4]] <- 0) -#> # A tibble: 4 x 4 -#> n c li ...4 -#> -#> 1 1 e 0 -#> 2 NA f 0 -#> 3 3 g 0 -#> 4 NA h 0 +with_df(tbl[[4]] <- 0) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -1818,7 +1807,7 @@ with_df(df[[5]] <- 0) ```r -with_tbl(tbl[[5]] <- 0) +with_df(tbl[[5]] <- 0) #> Error in `[[<-`: #> ! Can't assign to columns beyond the end with non-consecutive locations. #> i Input has size 3. @@ -1829,7 +1818,7 @@ with_tbl(tbl[[5]] <- 0) -`df[[j]] <- a` replaces the complete column so can change the type. +`tbl[[j]] <- a` replaces the complete column so can change the type.
@@ -1845,14 +1834,12 @@ with_df(df[[1]] <- df[[2]]) ```r -with_tbl(tbl[[1]] <- tbl[[2]]) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 e e -#> 2 f f -#> 3 g g -#> 4 h h +with_df(tbl[[1]] <- tbl[[2]]) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ```
@@ -1869,14 +1856,12 @@ with_df(df[[2]] <- df[[3]]) ```r -with_tbl(tbl[[2]] <- tbl[[3]]) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 -#> 2 NA -#> 3 3 -#> 4 NA +with_df(tbl[[2]] <- tbl[[3]]) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ```
@@ -1893,14 +1878,12 @@ with_df(df[[3]] <- df2[[1]]) ```r -with_tbl(tbl[[3]] <- tbl2[[1]]) -#> # A tibble: 4 x 3 -#> n c li$n $c $li -#> -#> 1 1 e 1 e -#> 2 NA f NA f -#> 3 3 g 3 g -#> 4 NA h NA h +with_df(tbl[[3]] <- tbl2[[1]]) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ```
@@ -1922,16 +1905,17 @@ with_df2(df2[[1]] <- df2[[2]]) ```r -with_tbl2(tbl2[[1]] <- tbl2[[2]]) -#> # A tibble: 4 x 2 -#> tb[,1] [,2] [,3] [,4] m[,1] -#> -#> 1 1 0 0 0 1 -#> 2 0 1 0 0 0 -#> 3 0 0 1 0 0 -#> 4 0 0 0 1 0 -#> # ... with 1 more variable: -#> # m[2:4] +with_df2(tbl2[[1]] <- tbl2[[2]]) +#> tb.n tb.c tb.li m.1 m.2 m.3 +#> 1 1 e 9 1 0 0 +#> 2 NA f 10, 11 0 1 0 +#> 3 3 g 12, 13, 14 0 0 1 +#> 4 NA h text 0 0 0 +#> m.4 +#> 1 0 +#> 2 0 +#> 3 0 +#> 4 1 ```
@@ -1948,14 +1932,17 @@ with_df2(df2[[2]] <- df[[1]]) ```r -with_tbl2(tbl2[[2]] <- tbl[[1]]) -#> # A tibble: 4 x 2 -#> tb$n $c $li m -#> -#> 1 1 e 1 -#> 2 NA f NA -#> 3 3 g 3 -#> 4 NA h NA +with_df2(tbl2[[2]] <- tbl[[1]]) +#> tb.n tb.c tb.li m.1 m.2 m.3 +#> 1 1 e 9 1 0 0 +#> 2 NA f 10, 11 0 1 0 +#> 3 3 g 12, 13, 14 0 0 1 +#> 4 NA h text 0 0 0 +#> m.4 +#> 1 0 +#> 2 0 +#> 3 0 +#> 4 1 ```
@@ -1976,14 +1963,12 @@ with_df(df[[1]] <- NULL) ```r -with_tbl(tbl[[1]] <- NULL) -#> # A tibble: 4 x 2 -#> c li -#> -#> 1 e -#> 2 f -#> 3 g -#> 4 h +with_df(tbl[[1]] <- NULL) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2000,14 +1985,17 @@ with_df2(df2[[2]] <- NULL) ```r -with_tbl2(tbl2[[2]] <- NULL) -#> # A tibble: 4 x 1 -#> tb$n $c $li -#> -#> 1 1 e -#> 2 NA f -#> 3 3 g -#> 4 NA h +with_df2(tbl2[[2]] <- NULL) +#> tb.n tb.c tb.li m.1 m.2 m.3 +#> 1 1 e 9 1 0 0 +#> 2 NA f 10, 11 0 1 0 +#> 3 3 g 12, 13, 14 0 0 1 +#> 4 NA h text 0 0 0 +#> m.4 +#> 1 0 +#> 2 0 +#> 3 0 +#> 4 1 ``` @@ -2028,14 +2016,12 @@ with_df(df[["q"]] <- NULL) ```r -with_tbl(tbl[["q"]] <- NULL) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 e -#> 2 NA f -#> 3 3 g -#> 4 NA h +with_df(tbl[["q"]] <- NULL) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2060,14 +2046,12 @@ with_df(df$n <- 0) ```r -with_tbl(tbl$n <- 0) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 0 e -#> 2 0 f -#> 3 0 g -#> 4 0 h +with_df(tbl$n <- 0) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2084,14 +2068,12 @@ with_df(df[["n"]] <- 0) ```r -with_tbl(tbl[["n"]] <- 0) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 0 e -#> 2 0 f -#> 3 0 g -#> 4 0 h +with_df(tbl[["n"]] <- 0) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2110,14 +2092,12 @@ with_df(df$"n" <- 0) ```r -with_tbl(tbl$"n" <- 0) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 0 e -#> 2 0 f -#> 3 0 g -#> 4 0 h +with_df(tbl$"n" <- 0) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2138,14 +2118,12 @@ with_df(df$l <- 0) ```r -with_tbl(tbl$l <- 0) -#> # A tibble: 4 x 4 -#> n c li l -#> -#> 1 1 e 0 -#> 2 NA f 0 -#> 3 3 g 0 -#> 4 NA h 0 +with_df(tbl$l <- 0) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2162,14 +2140,12 @@ with_df(df[["l"]] <- 0) ```r -with_tbl(tbl[["l"]] <- 0) -#> # A tibble: 4 x 4 -#> n c li l -#> -#> 1 1 e 0 -#> 2 NA f 0 -#> 3 3 g 0 -#> 4 NA h 0 +with_df(tbl[["l"]] <- 0) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2197,14 +2173,12 @@ with_df(df[1:2] <- list("x", 4:1)) ```r -with_tbl(tbl[1:2] <- list("x", 4:1)) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 x 4 -#> 2 x 3 -#> 3 x 2 -#> 4 x 1 +with_df(tbl[1:2] <- list("x", 4:1)) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2221,14 +2195,12 @@ with_df(df[c("li", "x", "c")] <- list("x", 4:1, NULL)) ```r -with_tbl(tbl[c("li", "x", "c")] <- list("x", 4:1, NULL)) -#> # A tibble: 4 x 3 -#> n li x -#> -#> 1 1 x 4 -#> 2 NA x 3 -#> 3 3 x 2 -#> 4 NA x 1 +with_df(tbl[c("li", "x", "c")] <- list("x", 4:1, NULL)) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2249,14 +2221,12 @@ with_df(df[1:2] <- list(1)) ```r -with_tbl(tbl[1:2] <- list(1)) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 1 -#> 2 1 1 -#> 3 1 1 -#> 4 1 1 +with_df(tbl[1:2] <- list(1)) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2277,7 +2247,7 @@ with_df(df[1:2] <- list(0, 0, 0)) ```r -with_tbl(tbl[1:2] <- list(0, 0, 0)) +with_df(tbl[1:2] <- list(0, 0, 0)) #> Error in `[<-`: #> ! Can't recycle `list(0, 0, 0)` (size 3) to size 2. ``` @@ -2296,7 +2266,7 @@ with_df(df[1:3] <- list(0, 0)) ```r -with_tbl(tbl[1:3] <- list(0, 0)) +with_df(tbl[1:3] <- list(0, 0)) #> Error in `[<-`: #> ! Can't recycle `list(0, 0)` (size 2) to size 3. ``` @@ -2315,7 +2285,7 @@ with_df(df[c(1, 1)] <- list(1, 2)) ```r -with_tbl(tbl[c(1, 1)] <- list(1, 2)) +with_df(tbl[c(1, 1)] <- list(1, 2)) #> Error in `[<-`: #> ! Column index 1 is used more than once for assignment. ``` @@ -2338,14 +2308,12 @@ with_df(df[1:2] <- list(NULL, 4:1)) ```r -with_tbl(tbl[1:2] <- list(NULL, 4:1)) -#> # A tibble: 4 x 2 -#> c li -#> -#> 1 4 -#> 2 3 -#> 3 2 -#> 4 1 +with_df(tbl[1:2] <- list(NULL, 4:1)) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2362,7 +2330,7 @@ with_df(df[NA] <- list("x")) ```r -with_tbl(tbl[NA] <- list("x")) +with_df(tbl[NA] <- list("x")) #> Error in `[<-`: #> ! Can't use NA as column index with `[` at positions 1, 2, and 3. ``` @@ -2377,7 +2345,7 @@ with_df(df[NA_integer_] <- list("x")) ```r -with_tbl(tbl[NA_integer_] <- list("x")) +with_df(tbl[NA_integer_] <- list("x")) #> Error in `[<-`: #> ! Can't use NA as column index in a tibble for assignment. ``` @@ -2392,7 +2360,7 @@ with_df(df[NA_character_] <- list("x")) ```r -with_tbl(tbl[NA_character_] <- list("x")) +with_df(tbl[NA_character_] <- list("x")) #> Error in `[<-`: #> ! Can't use NA as column index in a tibble for assignment. ``` @@ -2415,14 +2383,12 @@ with_df(df[1] <- df[2]) ```r -with_tbl(tbl[1] <- tbl[2]) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 e e -#> 2 f f -#> 3 g g -#> 4 h h +with_df(tbl[1] <- tbl[2]) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2439,14 +2405,12 @@ with_df(df[2] <- df[3]) ```r -with_tbl(tbl[2] <- tbl[3]) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 -#> 2 NA -#> 3 3 -#> 4 NA +with_df(tbl[2] <- tbl[3]) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2463,14 +2427,12 @@ with_df(df[3] <- df2[1]) ```r -with_tbl(tbl[3] <- tbl2[1]) -#> # A tibble: 4 x 3 -#> n c li$n $c $li -#> -#> 1 1 e 1 e -#> 2 NA f NA f -#> 3 3 g 3 g -#> 4 NA h NA h +with_df(tbl[3] <- tbl2[1]) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2492,16 +2454,17 @@ with_df2(df2[1] <- df2[2]) ```r -with_tbl2(tbl2[1] <- tbl2[2]) -#> # A tibble: 4 x 2 -#> tb[,1] [,2] [,3] [,4] m[,1] -#> -#> 1 1 0 0 0 1 -#> 2 0 1 0 0 0 -#> 3 0 0 1 0 0 -#> 4 0 0 0 1 0 -#> # ... with 1 more variable: -#> # m[2:4] +with_df2(tbl2[1] <- tbl2[2]) +#> tb.n tb.c tb.li m.1 m.2 m.3 +#> 1 1 e 9 1 0 0 +#> 2 NA f 10, 11 0 1 0 +#> 3 3 g 12, 13, 14 0 0 1 +#> 4 NA h text 0 0 0 +#> m.4 +#> 1 0 +#> 2 0 +#> 3 0 +#> 4 1 ``` @@ -2518,14 +2481,17 @@ with_df2(df2[2] <- df[1]) ```r -with_tbl2(tbl2[2] <- tbl[1]) -#> # A tibble: 4 x 2 -#> tb$n $c $li m -#> -#> 1 1 e 1 -#> 2 NA f NA -#> 3 3 g 3 -#> 4 NA h NA +with_df2(tbl2[2] <- tbl[1]) +#> tb.n tb.c tb.li m.1 m.2 m.3 +#> 1 1 e 9 1 0 0 +#> 2 NA f 10, 11 0 1 0 +#> 3 3 g 12, 13, 14 0 0 1 +#> 4 NA h text 0 0 0 +#> m.4 +#> 1 0 +#> 2 0 +#> 3 0 +#> 4 1 ``` @@ -2547,14 +2513,12 @@ with_df(df[c("x", "y")] <- tibble("x", x = 4:1)) ```r -with_tbl(tbl[c("x", "y")] <- tibble("x", x = 4:1)) -#> # A tibble: 4 x 5 -#> n c li x y -#> -#> 1 1 e x 4 -#> 2 NA f x 3 -#> 3 3 g x 2 -#> 4 NA h x 1 +with_df(tbl[c("x", "y")] <- tibble("x", x = 4:1)) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2571,14 +2535,12 @@ with_df(df[3:4] <- list("x", x = 4:1)) ```r -with_tbl(tbl[3:4] <- list("x", x = 4:1)) -#> # A tibble: 4 x 4 -#> n c li x -#> -#> 1 1 e x 4 -#> 2 NA f x 3 -#> 3 3 g x 2 -#> 4 NA h x 1 +with_df(tbl[3:4] <- list("x", x = 4:1)) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2595,14 +2557,12 @@ with_df(df[4] <- list(4:1)) ```r -with_tbl(tbl[4] <- list(4:1)) -#> # A tibble: 4 x 4 -#> n c li ...4 -#> -#> 1 1 e 4 -#> 2 NA f 3 -#> 3 3 g 2 -#> 4 NA h 1 +with_df(tbl[4] <- list(4:1)) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2615,7 +2575,7 @@ with_df(df[5] <- list(4:1)) ```r -with_tbl(tbl[5] <- list(4:1)) +with_df(tbl[5] <- list(4:1)) #> Error in `[<-`: #> ! Can't assign to columns beyond the end with non-consecutive locations. #> i Input has size 3. @@ -2640,14 +2600,12 @@ with_df(df[is.na(df)] <- 4) ```r -with_tbl(tbl[is.na(tbl)] <- 4) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 e -#> 2 4 f -#> 3 3 g -#> 4 4 h +with_df(tbl[is.na(df)] <- 4) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2664,9 +2622,9 @@ with_df(df[is.na(df)] <- 1:2) ```r -with_tbl(tbl[is.na(tbl)] <- 1:2) +with_df(tbl[is.na(df)] <- 1:2) #> Error in `[<-`: -#> ! Subscript `is.na(tbl)` is a matrix, the data `1:2` must have size 1. +#> ! Subscript `is.na(df)` is a matrix, the data `1:2` must have size 1. ``` @@ -2683,7 +2641,7 @@ with_df(df[matrix(c(rep(TRUE, 5), rep(FALSE, 7)), ncol = 3)] <- 4) ```r -with_tbl(tbl[matrix(c(rep(TRUE, 5), rep(FALSE, 7)), ncol = 3)] <- 4) +with_df(tbl[matrix(c(rep(TRUE, 5), rep(FALSE, 7)), ncol = 3)] <- 4) #> Error in `[<-`: #> ! Assigned data `4` must be compatible with existing data. #> i Error occurred for column `c`. @@ -2713,14 +2671,12 @@ with_df(df[1:2] <- matrix(8:1, ncol = 2)) ```r -with_tbl(tbl[1:2] <- matrix(8:1, ncol = 2)) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 8 4 -#> 2 7 3 -#> 3 6 2 -#> 4 5 1 +with_df(tbl[1:2] <- matrix(8:1, ncol = 2)) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2737,7 +2693,7 @@ with_df(df[1:3, 1:2] <- matrix(6:1, ncol = 2)) ```r -with_tbl(tbl[1:3, 1:2] <- matrix(6:1, ncol = 2)) +with_df(tbl[1:3, 1:2] <- matrix(6:1, ncol = 2)) #> Error in `[<-`: #> ! Assigned data `matrix(6:1, ncol = 2)` must be compatible with existing data. #> i Error occurred for column `c`. @@ -2759,14 +2715,12 @@ with_df(df[1:2] <- array(4:1, dim = c(4, 1, 1))) ```r -with_tbl(tbl[1:2] <- array(4:1, dim = c(4, 1, 1))) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 4 4 -#> 2 3 3 -#> 3 2 2 -#> 4 1 1 +with_df(tbl[1:2] <- array(4:1, dim = c(4, 1, 1))) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2783,14 +2737,12 @@ with_df(df[1:2] <- array(8:1, dim = c(4, 2, 1))) ```r -with_tbl(tbl[1:2] <- array(8:1, dim = c(4, 2, 1))) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 8 4 -#> 2 7 3 -#> 3 6 2 -#> 4 5 1 +with_df(tbl[1:2] <- array(8:1, dim = c(4, 2, 1))) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2807,7 +2759,7 @@ with_df(df[1:2] <- array(8:1, dim = c(2, 1, 4))) ```r -with_tbl(tbl[1:2] <- array(8:1, dim = c(2, 1, 4))) +with_df(tbl[1:2] <- array(8:1, dim = c(2, 1, 4))) #> Error in `[<-`: #> ! `array(8:1, dim = c(2, 1, 4))` must be a vector, a bare list, a data frame, a matrix, or NULL. ``` @@ -2826,7 +2778,7 @@ with_df(df[1:2] <- array(8:1, dim = c(4, 1, 2))) ```r -with_tbl(tbl[1:2] <- array(8:1, dim = c(4, 1, 2))) +with_df(tbl[1:2] <- array(8:1, dim = c(4, 1, 2))) #> Error in `[<-`: #> ! `array(8:1, dim = c(4, 1, 2))` must be a vector, a bare list, a data frame, a matrix, or NULL. ``` @@ -2852,14 +2804,12 @@ with_df(df[1] <- 0) ```r -with_tbl(tbl[1] <- 0) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 0 e -#> 2 0 f -#> 3 0 g -#> 4 0 h +with_df(tbl[1] <- 0) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2876,14 +2826,12 @@ with_df(df[1] <- list(0)) ```r -with_tbl(tbl[1] <- list(0)) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 0 e -#> 2 0 f -#> 3 0 g -#> 4 0 h +with_df(tbl[1] <- list(0)) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2904,14 +2852,12 @@ with_df(df[1] <- list(matrix(1:8, ncol = 2))) ```r -with_tbl(tbl[1] <- list(matrix(1:8, ncol = 2))) -#> # A tibble: 4 x 3 -#> n[,1] [,2] c li -#> -#> 1 1 5 e -#> 2 2 6 f -#> 3 3 7 g -#> 4 4 8 h +with_df(tbl[1] <- list(matrix(1:8, ncol = 2))) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2934,14 +2880,12 @@ with_df(df[1:2] <- list(matrix(1:8, ncol = 2))) ```r -with_tbl(tbl[1:2] <- list(matrix(1:8, ncol = 2))) -#> # A tibble: 4 x 3 -#> n[,1] [,2] c[,1] [,2] li -#> -#> 1 1 5 1 5 -#> 2 2 6 2 6 -#> 3 3 7 3 7 -#> 4 4 8 4 8 +with_df(tbl[1:2] <- list(matrix(1:8, ncol = 2))) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2965,14 +2909,12 @@ with_df(df[1] <- NULL) ```r -with_tbl(tbl[1] <- NULL) -#> # A tibble: 4 x 2 -#> c li -#> -#> 1 e -#> 2 f -#> 3 g -#> 4 h +with_df(tbl[1] <- NULL) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -2989,14 +2931,12 @@ with_df(df[, 2:3] <- NULL) ```r -with_tbl(tbl[, 2:3] <- NULL) -#> # A tibble: 4 x 1 -#> n -#> -#> 1 1 -#> 2 NA -#> 3 3 -#> 4 NA +with_df(tbl[, 2:3] <- NULL) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -3009,7 +2949,7 @@ with_df(df[1, 2:3] <- NULL) ```r -with_tbl(tbl[1, 2:3] <- NULL) +with_df(tbl[1, 2:3] <- NULL) #> Error in `[<-`: #> ! `NULL` must be a vector, a bare list, a data frame or a matrix. ``` @@ -3032,7 +2972,7 @@ with_df(df[1] <- mean) ```r -with_tbl(tbl[1] <- mean) +with_df(tbl[1] <- mean) #> Error in `[<-`: #> ! `mean` must be a vector, a bare list, a data frame, a matrix, or NULL. ``` @@ -3071,7 +3011,7 @@ with_df(df[1] <- lm(mpg ~ wt, data = mtcars)) ```r -with_tbl(tbl[1] <- lm(mpg ~ wt, data = mtcars)) +with_df(tbl[1] <- lm(mpg ~ wt, data = mtcars)) #> Error in `[<-`: #> ! `lm(mpg ~ wt, data = mtcars)` must be a vector, a bare list, a data frame, a matrix, or NULL. ``` @@ -3100,14 +3040,12 @@ with_df(df[2:3, ] <- df[1, ]) ```r -with_tbl(tbl[2:3, ] <- tbl[1, ]) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 e -#> 2 1 e -#> 3 1 e -#> 4 NA h +with_df(tbl[2:3, ] <- tbl[1, ]) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -3124,14 +3062,12 @@ with_df(df[c(FALSE, TRUE, TRUE, FALSE), ] <- df[1, ]) ```r -with_tbl(tbl[c(FALSE, TRUE, TRUE, FALSE), ] <- tbl[1, ]) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 e -#> 2 1 e -#> 3 1 e -#> 4 NA h +with_df(tbl[c(FALSE, TRUE, TRUE, FALSE), ] <- tbl[1, ]) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -3150,7 +3086,7 @@ with_df(df[0:2, ] <- df[1, ]) ```r -with_tbl(tbl[0:2, ] <- tbl[1, ]) +with_df(tbl[0:2, ] <- tbl[1, ]) #> Error in `[<-`: #> ! Can't assign rows with `0:2`. #> x Subscript `0:2` can't contain `0` values. @@ -3171,7 +3107,7 @@ with_df(df[0, ] <- df[1, ]) ```r -with_tbl(tbl[0, ] <- tbl[1, ]) +with_df(tbl[0, ] <- tbl[1, ]) #> Error in `[<-`: #> ! Can't assign rows with `0`. #> x Subscript `0` can't contain `0` values. @@ -3192,14 +3128,12 @@ with_df(df[-2, ] <- df[1, ]) ```r -with_tbl(tbl[-2, ] <- tbl[1, ]) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 e -#> 2 NA f -#> 3 1 e -#> 4 1 e +with_df(tbl[-2, ] <- tbl[1, ]) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -3212,7 +3146,7 @@ with_df(df[-1:2, ] <- df[1, ]) ```r -with_tbl(tbl[-1:2, ] <- tbl[1, ]) +with_df(tbl[-1:2, ] <- tbl[1, ]) #> Error in `[<-`: #> ! Can't assign rows with `-1:2`. #> x Subscript `-1:2` can't contain `0` values. @@ -3229,7 +3163,7 @@ with_df(df[NA_integer_, ] <- df[1, ]) ```r -with_tbl(tbl[NA_integer_, ] <- tbl[1, ]) +with_df(tbl[NA_integer_, ] <- tbl[1, ]) #> Error in `[<-`: #> ! Can't assign rows with `NA_integer_`. #> x Subscript `NA_integer_` can't contain missing values. @@ -3246,7 +3180,7 @@ with_df2(df2[NA_integer_, ] <- df2[1, ]) ```r -with_tbl2(tbl2[NA_integer_, ] <- tbl2[1, ]) +with_df2(tbl2[NA_integer_, ] <- tbl2[1, ]) #> Error in `[<-`: #> ! Can't assign rows with `NA_integer_`. #> x Subscript `NA_integer_` can't contain missing values. @@ -3267,14 +3201,12 @@ with_df(df[TRUE, ] <- df[1, ]) ```r -with_tbl(tbl[TRUE, ] <- tbl[1, ]) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 e -#> 2 1 e -#> 3 1 e -#> 4 1 e +with_df(tbl[TRUE, ] <- tbl[1, ]) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -3291,14 +3223,12 @@ with_df(df[FALSE, ] <- df[1, ]) ```r -with_tbl(tbl[FALSE, ] <- tbl[1, ]) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 e -#> 2 NA f -#> 3 3 g -#> 4 NA h +with_df(tbl[FALSE, ] <- tbl[1, ]) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -3311,7 +3241,7 @@ with_df(df[NA, ] <- df[1, ]) ```r -with_tbl(tbl[NA, ] <- tbl[1, ]) +with_df(tbl[NA, ] <- tbl[1, ]) #> Error in `[<-`: #> ! Can't use NA as row index in a tibble for assignment. ``` @@ -3334,14 +3264,12 @@ with_df(df[2:3, ] <- df[1, ]) ```r -with_tbl(tbl[2:3, ] <- tbl[1, ]) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 e -#> 2 1 e -#> 3 1 e -#> 4 NA h +with_df(tbl[2:3, ] <- tbl[1, ]) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -3358,14 +3286,12 @@ with_df(df[2:3, ] <- list(df$n[1], df$c[1:2], df$li[1])) ```r -with_tbl(tbl[2:3, ] <- list(tbl$n[1], tbl$c[1:2], tbl$li[1])) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 e -#> 2 1 e -#> 3 1 f -#> 4 NA h +with_df(tbl[2:3, ] <- list(tbl$n[1], tbl$c[1:2], tbl$li[1])) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -3378,7 +3304,7 @@ with_df(df[2:4, ] <- df[1:2, ]) ```r -with_tbl(tbl[2:4, ] <- tbl[1:2, ]) +with_df(tbl[2:4, ] <- tbl[1:2, ]) #> Error in `[<-`: #> ! Assigned data `tbl[1:2, ]` must be compatible with row subscript `2:4`. #> x 3 rows must be assigned. @@ -3400,16 +3326,17 @@ with_df2(df2[2:4, ] <- df2[1, ]) ```r -with_tbl2(tbl2[2:4, ] <- tbl2[1, ]) -#> # A tibble: 4 x 2 -#> tb$n $c $li m[,1] [,2] -#> -#> 1 1 e 1 0 -#> 2 1 e 1 0 -#> 3 1 e 1 0 -#> 4 1 e 1 0 -#> # ... with 1 more variable: -#> # m[3:4] +with_df2(tbl2[2:4, ] <- tbl2[1, ]) +#> tb.n tb.c tb.li m.1 m.2 m.3 +#> 1 1 e 9 1 0 0 +#> 2 NA f 10, 11 0 1 0 +#> 3 3 g 12, 13, 14 0 0 1 +#> 4 NA h text 0 0 0 +#> m.4 +#> 1 0 +#> 2 0 +#> 3 0 +#> 4 1 ``` @@ -3422,7 +3349,7 @@ with_df2(df2[2:4, ] <- df2[2:3, ]) ```r -with_tbl2(tbl2[2:4, ] <- tbl2[2:3, ]) +with_df2(tbl2[2:4, ] <- tbl2[2:3, ]) #> Error in `[<-`: #> ! Assigned data `tbl2[2:3, ]` must be compatible with row subscript `2:4`. #> x 3 rows must be assigned. @@ -3452,15 +3379,12 @@ with_df(df[5, ] <- df[1, ]) ```r -with_tbl(tbl[5, ] <- tbl[1, ]) -#> # A tibble: 5 x 3 -#> n c li -#> -#> 1 1 e -#> 2 NA f -#> 3 3 g -#> 4 NA h -#> 5 1 e +with_df(tbl[5, ] <- tbl[1, ]) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -3480,17 +3404,12 @@ with_df(df[5:7, ] <- df[1, ]) ```r -with_tbl(tbl[5:7, ] <- tbl[1, ]) -#> # A tibble: 7 x 3 -#> n c li -#> -#> 1 1 e -#> 2 NA f -#> 3 3 g -#> 4 NA h -#> 5 1 e -#> 6 1 e -#> 7 1 e +with_df(tbl[5:7, ] <- tbl[1, ]) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -3509,7 +3428,7 @@ with_df(df[6, ] <- df[1, ]) ```r -with_tbl(tbl[6, ] <- tbl[1, ]) +with_df(tbl[6, ] <- tbl[1, ]) #> Error in `[<-`: #> ! Can't assign to rows beyond the end with non-consecutive locations. #> i Input has size 4. @@ -3530,7 +3449,7 @@ with_df(df[-5, ] <- df[1, ]) ```r -with_tbl(tbl[-5, ] <- tbl[1, ]) +with_df(tbl[-5, ] <- tbl[1, ]) #> Error in `[<-`: #> ! Can't negate rows past the end. #> i Location 5 doesn't exist. @@ -3551,7 +3470,7 @@ with_df(df[-(5:7), ] <- df[1, ]) ```r -with_tbl(tbl[-(5:7), ] <- tbl[1, ]) +with_df(tbl[-(5:7), ] <- tbl[1, ]) #> Error in `[<-`: #> ! Can't negate rows past the end. #> i Locations 5, 6, and 7 don't exist. @@ -3572,7 +3491,7 @@ with_df(df[-6, ] <- df[1, ]) ```r -with_tbl(tbl[-6, ] <- tbl[1, ]) +with_df(tbl[-6, ] <- tbl[1, ]) #> Error in `[<-`: #> ! Can't negate rows past the end. #> i Location 6 doesn't exist. @@ -3597,14 +3516,12 @@ with_df(df[as.character(1:3), ] <- df[1, ]) ```r -with_tbl(tbl[as.character(1:3), ] <- tbl[1, ]) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 e -#> 2 1 e -#> 3 1 e -#> 4 NA h +with_df(tbl[as.character(1:3), ] <- tbl[1, ]) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -3626,7 +3543,7 @@ with_df(df[as.character(-(1:3)), ] <- df[1, ]) ```r -with_tbl(tbl[as.character(-(1:3)), ] <- tbl[1, ]) +with_df(tbl[as.character(-(1:3)), ] <- tbl[1, ]) #> Warning: The `i` argument of `[.tbl_df` must use valid row names as of tibble 3.0.0. #> i Use `NA_integer_` as row index to obtain a row full of `NA` values. #> Error in `[<-`: @@ -3648,7 +3565,7 @@ with_df(df[as.character(3:5), ] <- df[1, ]) ```r -with_tbl(tbl[as.character(3:5), ] <- tbl[1, ]) +with_df(tbl[as.character(3:5), ] <- tbl[1, ]) #> Warning: The `i` argument of `[.tbl_df` must use valid row names as of tibble 3.0.0. #> i Use `NA_integer_` as row index to obtain a row full of `NA` values. #> Error in `[<-`: @@ -3672,7 +3589,7 @@ with_df(df[as.character(-(3:5)), ] <- df[1, ]) ```r -with_tbl(tbl[as.character(-(3:5)), ] <- tbl[1, ]) +with_df(tbl[as.character(-(3:5)), ] <- tbl[1, ]) #> Warning: The `i` argument of `[.tbl_df` must use valid row names as of tibble 3.0.0. #> i Use `NA_integer_` as row index to obtain a row full of `NA` values. #> Error in `[<-`: @@ -3689,7 +3606,7 @@ with_df(df[NA_character_, ] <- df[1, ]) ```r -with_tbl(tbl[NA_character_, ] <- tbl[1, ]) +with_df(tbl[NA_character_, ] <- tbl[1, ]) #> Error in `[<-`: #> ! Can't use NA as row index in a tibble for assignment. ``` @@ -3722,7 +3639,7 @@ with_df(df[2:3, 1] <- df[1:2, 2]) ```r -with_tbl(tbl[2:3, 1] <- tbl[1:2, 2]) +with_df(tbl[2:3, 1] <- tbl[1:2, 2]) #> Error in `[<-`: #> ! Assigned data `tbl[1:2, 2]` must be compatible with existing data. #> i Error occurred for column `n`. @@ -3748,7 +3665,7 @@ with_df(df[2:3, 2] <- df[1:2, 3]) ```r -with_tbl(tbl[2:3, 2] <- tbl[1:2, 3]) +with_df(tbl[2:3, 2] <- tbl[1:2, 3]) #> Error in `[<-`: #> ! Assigned data `tbl[1:2, 3]` must be compatible with existing data. #> i Error occurred for column `c`. @@ -3775,7 +3692,7 @@ with_df(df[2:3, 3] <- df2[1:2, 1]) ```r -with_tbl(tbl[2:3, 3] <- tbl2[1:2, 1]) +with_df(tbl[2:3, 3] <- tbl2[1:2, 1]) #> Error in `[<-`: #> ! Assigned data `tbl2[1:2, 1]` must be compatible with existing data. #> i Error occurred for column `li`. @@ -3801,7 +3718,7 @@ with_df2(df2[2:3, 1] <- df2[1:2, 2]) ```r -with_tbl2(tbl2[2:3, 1] <- tbl2[1:2, 2]) +with_df2(tbl2[2:3, 1] <- tbl2[1:2, 2]) #> Error in `[<-`: #> ! Assigned data `tbl2[1:2, 2]` must be compatible with existing data. #> i Error occurred for column `tb`. @@ -3828,16 +3745,17 @@ with_df2(df2[2:3, 2] <- df[1:2, 1]) ```r -with_tbl2(tbl2[2:3, 2] <- tbl[1:2, 1]) -#> # A tibble: 4 x 2 -#> tb$n $c $li m[,1] [,2] -#> -#> 1 1 e 1 0 -#> 2 NA f 1 1 -#> 3 3 g NA NA -#> 4 NA h 0 0 -#> # ... with 1 more variable: -#> # m[3:4] +with_df2(tbl2[2:3, 2] <- tbl[1:2, 1]) +#> tb.n tb.c tb.li m.1 m.2 m.3 +#> 1 1 e 9 1 0 0 +#> 2 NA f 10, 11 0 1 0 +#> 3 3 g 12, 13, 14 0 0 1 +#> 4 NA h text 0 0 0 +#> m.4 +#> 1 0 +#> 2 0 +#> 3 0 +#> 4 1 ``` @@ -3858,14 +3776,12 @@ with_df({df$x <- NA; df[2:3, "x"] <- 3:2}) ```r -with_tbl({tbl$x <- NA; tbl[2:3, "x"] <- 3:2}) -#> # A tibble: 4 x 4 -#> n c li x -#> -#> 1 1 e NA -#> 2 NA f 3 -#> 3 3 g 2 -#> 4 NA h NA +with_df({tbl$x <- NA; tbl[2:3, "x"] <- 3:2}) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -3882,14 +3798,12 @@ with_df({df[2:3, 2:3] <- NA}) ```r -with_tbl({tbl[2:3, 2:3] <- NA}) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 e -#> 2 NA -#> 3 3 -#> 4 NA h +with_df({tbl[2:3, 2:3] <- NA}) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -3910,14 +3824,12 @@ with_df({df$x <- NA_integer_; df[2:3, "x"] <- 3:2}) ```r -with_tbl({tbl$x <- NA_integer_; tbl[2:3, "x"] <- 3:2}) -#> # A tibble: 4 x 4 -#> n c li x -#> -#> 1 1 e NA -#> 2 NA f 3 -#> 3 3 g 2 -#> 4 NA h NA +with_df({tbl$x <- NA_integer_; tbl[2:3, "x"] <- 3:2}) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -3939,14 +3851,12 @@ with_df(df[2:3, "n"] <- 1) ```r -with_tbl(tbl[2:3, "n"] <- 1) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 e -#> 2 1 f -#> 3 1 g -#> 4 NA h +with_df(tbl[2:3, "n"] <- 1) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -3963,14 +3873,12 @@ with_df(df[2:3, "x"] <- 1) ```r -with_tbl(tbl[2:3, "x"] <- 1) -#> # A tibble: 4 x 4 -#> n c li x -#> -#> 1 1 e NA -#> 2 NA f 1 -#> 3 3 g 1 -#> 4 NA h NA +with_df(tbl[2:3, "x"] <- 1) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -3983,7 +3891,7 @@ with_df(df[2:3, "n"] <- NULL) ```r -with_tbl(tbl[2:3, "n"] <- NULL) +with_df(tbl[2:3, "n"] <- NULL) #> Error in `[<-`: #> ! `NULL` must be a vector, a bare list, a data frame or a matrix. ``` @@ -4007,15 +3915,12 @@ with_df(df[5, "n"] <- list(0L)) ```r -with_tbl(tbl[5, "n"] <- list(0L)) -#> # A tibble: 5 x 3 -#> n c li -#> -#> 1 1 e -#> 2 NA f -#> 3 3 g -#> 4 NA h -#> 5 0 +with_df(tbl[5, "n"] <- list(0L)) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -4044,14 +3949,12 @@ with_df(df[[1, 1]] <- 0) ```r -with_tbl(tbl[[1, 1]] <- 0) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 0 e -#> 2 NA f -#> 3 3 g -#> 4 NA h +with_df(tbl[[1, 1]] <- 0) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -4068,14 +3971,12 @@ with_df(df[1, ][[1]] <- 0) ```r -with_tbl(tbl[1, ][[1]] <- 0) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 0 e -#> 2 NA f -#> 3 3 g -#> 4 NA h +with_df(tbl[1, ][[1]] <- 0) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -4092,14 +3993,12 @@ with_df(df[[1, 3]] <- list(NULL)) ```r -with_tbl(tbl[[1, 3]] <- list(NULL)) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 e -#> 2 NA f -#> 3 3 g -#> 4 NA h +with_df(tbl[[1, 3]] <- list(NULL)) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -4116,14 +4015,12 @@ with_df(df[1, ][[3]] <- list(NULL)) ```r -with_tbl(tbl[1, ][[3]] <- list(NULL)) -#> # A tibble: 4 x 3 -#> n c li -#> -#> 1 1 e -#> 2 NA f -#> 3 3 g -#> 4 NA h +with_df(tbl[1, ][[3]] <- list(NULL)) +#> n c li +#> 1 1 e 9 +#> 2 NA f 10, 11 +#> 3 3 g 12, 13, 14 +#> 4 NA h text ``` @@ -4136,16 +4033,17 @@ with_df2(df2[[1, 1]] <- df[1, ]) ```r -with_tbl2(tbl2[[1, 1]] <- tbl[1, ]) -#> # A tibble: 4 x 2 -#> tb$n $c $li m[,1] [,2] -#> -#> 1 1 e 1 0 -#> 2 NA f 0 1 -#> 3 3 g 0 0 -#> 4 NA h 0 0 -#> # ... with 1 more variable: -#> # m[3:4] +with_df2(tbl2[[1, 1]] <- tbl[1, ]) +#> tb.n tb.c tb.li m.1 m.2 m.3 +#> 1 1 e 9 1 0 0 +#> 2 NA f 10, 11 0 1 0 +#> 3 3 g 12, 13, 14 0 0 1 +#> 4 NA h text 0 0 0 +#> m.4 +#> 1 0 +#> 2 0 +#> 3 0 +#> 4 1 ``` @@ -4167,16 +4065,17 @@ with_df2(df2[1, ][[1]] <- df[1, ]) ```r -with_tbl2(tbl2[1, ][[1]] <- tbl[1, ]) -#> # A tibble: 4 x 2 -#> tb$n $c $li m[,1] [,2] -#> -#> 1 1 e 1 0 -#> 2 NA f 0 1 -#> 3 3 g 0 0 -#> 4 NA h 0 0 -#> # ... with 1 more variable: -#> # m[3:4] +with_df2(tbl2[1, ][[1]] <- tbl[1, ]) +#> tb.n tb.c tb.li m.1 m.2 m.3 +#> 1 1 e 9 1 0 0 +#> 2 NA f 10, 11 0 1 0 +#> 3 3 g 12, 13, 14 0 0 1 +#> 4 NA h text 0 0 0 +#> m.4 +#> 1 0 +#> 2 0 +#> 3 0 +#> 4 1 ``` @@ -4189,16 +4088,17 @@ with_df2(df2[[1, 2]] <- t(1:4)) ```r -with_tbl2(tbl2[[1, 2]] <- t(1:4)) -#> # A tibble: 4 x 2 -#> tb$n $c $li m[,1] [,2] -#> -#> 1 1 e 1 2 -#> 2 NA f 0 1 -#> 3 3 g 0 0 -#> 4 NA h 0 0 -#> # ... with 1 more variable: -#> # m[3:4] +with_df2(tbl2[[1, 2]] <- t(1:4)) +#> tb.n tb.c tb.li m.1 m.2 m.3 +#> 1 1 e 9 1 0 0 +#> 2 NA f 10, 11 0 1 0 +#> 3 3 g 12, 13, 14 0 0 1 +#> 4 NA h text 0 0 0 +#> m.4 +#> 1 0 +#> 2 0 +#> 3 0 +#> 4 1 ``` @@ -4220,16 +4120,17 @@ with_df2(df2[1, ][[2]] <- t(1:4)) ```r -with_tbl2(tbl2[1, ][[2]] <- t(1:4)) -#> # A tibble: 4 x 2 -#> tb$n $c $li m[,1] [,2] -#> -#> 1 1 e 1 2 -#> 2 NA f 0 1 -#> 3 3 g 0 0 -#> 4 NA h 0 0 -#> # ... with 1 more variable: -#> # m[3:4] +with_df2(tbl2[1, ][[2]] <- t(1:4)) +#> tb.n tb.c tb.li m.1 m.2 m.3 +#> 1 1 e 9 1 0 0 +#> 2 NA f 10, 11 0 1 0 +#> 3 3 g 12, 13, 14 0 0 1 +#> 4 NA h text 0 0 0 +#> m.4 +#> 1 0 +#> 2 0 +#> 3 0 +#> 4 1 ``` @@ -4258,7 +4159,7 @@ with_df(df[[1:2, 1]] <- 0) ```r -with_tbl(tbl[[1:2, 1]] <- 0) +with_df(tbl[[1:2, 1]] <- 0) #> Error in `[[<-`: #> ! Can't assign row with `1:2`. #> x Subscript `1:2` must be size 1, not 2.