|
with_tbl(tbl[] <- 1)
#> # A tibble: 4 × 3
#> a b cd
#> <dbl> <dbl> <dbl>
#> 1 1 1 1
#> 2 1 1 1
#> 3 1 1 1
#> 4 1 1 1
|
|
with_tbl(tbl[] <- 4:1)
#> # A tibble: 4 × 3
#> a b cd
#> <int> <int> <int>
#> 1 4 4 4
#> 2 3 3 3
#> 3 2 2 2
#> 4 1 1 1
|
with_df(df[] <- 3:1)
#> a b cd
#> 1 3 2 1
#> 2 2 1 3
#> 3 1 3 2
#> 4 3 2 1
|
#> Error: Assigned data `3:1` must be
#> compatible with existing data.
#> x Existing data has 4 rows.
#> x Assigned data has 3 rows.
#> ℹ Only vectors of size 1 are recycled.
|
#> Error in `[<-.data.frame`(`*tmp*`, ,
#> value = 5:1): replacement has 5 items,
#> need 12
|
#> Error: Assigned data `5:1` must be
#> compatible with existing data.
#> x Existing data has 4 rows.
#> x Assigned data has 5 rows.
#> ℹ Only vectors of size 1 are recycled.
|
with_df(df[] <- data.frame(1, "x"))
#> a b cd
#> 1 1 x 1
#> 2 1 x 1
#> 3 1 x 1
#> 4 1 x 1
|
#> Error: Can't recycle input of size 2 to
#> size 3.
|
|
with_tbl(tbl[] <- data.frame(4:1, "x", 2))
#> # A tibble: 4 × 3
#> a b cd
#> <int> <chr> <dbl>
#> 1 4 x 2
#> 2 3 x 2
#> 3 2 x 2
#> 4 1 x 2
|
|
with_tbl(tbl[] <- data.frame(1, "x", 2))
#> # A tibble: 4 × 3
#> a b cd
#> <dbl> <chr> <dbl>
#> 1 1 x 2
#> 2 1 x 2
#> 3 1 x 2
#> 4 1 x 2
|
#> Warning in `[<-.data.frame`(`*tmp*`, ,
#> value = structure(list(X1 = 1, X.x. =
#> "x", : provided 4 variables to replace 3
#> variables
#> a b cd
#> 1 1 x 2
#> 2 1 x 2
#> 3 1 x 2
#> 4 1 x 2
|
#> Error: Can't recycle input of size 4 to
#> size 3.
|
|
with_tbl(tbl[] <- tbl)
#> # A tibble: 4 × 3
#> a b cd
#> <int> <chr> <list>
#> 1 1 e <dbl [1]>
#> 2 2 f <int [2]>
#> 3 3 g <int [3]>
#> 4 4 h <chr [1]>
|
|
with_tbl(tbl[,] <- 1)
#> # A tibble: 4 × 3
#> a b cd
#> <dbl> <dbl> <dbl>
#> 1 1 1 1
#> 2 1 1 1
#> 3 1 1 1
#> 4 1 1 1
|
|
with_tbl(tbl[,] <- 4:1)
#> # A tibble: 4 × 3
#> a b cd
#> <int> <int> <int>
#> 1 4 4 4
#> 2 3 3 3
#> 3 2 2 2
#> 4 1 1 1
|
with_df(df[,] <- 3:1)
#> a b cd
#> 1 3 2 1
#> 2 2 1 3
#> 3 1 3 2
#> 4 3 2 1
|
#> Error: Assigned data `3:1` must be
#> compatible with existing data.
#> x Existing data has 4 rows.
#> x Assigned data has 3 rows.
#> ℹ Only vectors of size 1 are recycled.
|
#> Error in `[<-.data.frame`(`*tmp*`, , ,
#> value = 5:1): replacement has 5 items,
#> need 12
|
#> Error: Assigned data `5:1` must be
#> compatible with existing data.
#> x Existing data has 4 rows.
#> x Assigned data has 5 rows.
#> ℹ Only vectors of size 1 are recycled.
|
with_df(df[,] <- data.frame(1, "x"))
#> a b cd
#> 1 1 x 1
#> 2 1 x 1
#> 3 1 x 1
#> 4 1 x 1
|
#> Error: Can't recycle input of size 2 to
#> size 3.
|
|
with_tbl(tbl[,] <- data.frame(4:1, "x", 2))
#> # A tibble: 4 × 3
#> a b cd
#> <int> <chr> <dbl>
#> 1 4 x 2
#> 2 3 x 2
#> 3 2 x 2
#> 4 1 x 2
|
|
with_tbl(tbl[,] <- data.frame(1, "x", 2))
#> # A tibble: 4 × 3
#> a b cd
#> <dbl> <chr> <dbl>
#> 1 1 x 2
#> 2 1 x 2
#> 3 1 x 2
#> 4 1 x 2
|
#> Warning in `[<-.data.frame`(`*tmp*`, , ,
#> value = structure(list(X1 = 1, :
#> provided 4 variables to replace 3
#> variables
#> a b cd
#> 1 1 x 2
#> 2 1 x 2
#> 3 1 x 2
#> 4 1 x 2
|
#> Error: Can't recycle input of size 4 to
#> size 3.
|
|
with_tbl(tbl[,] <- tbl)
#> # A tibble: 4 × 3
#> a b cd
#> <int> <chr> <list>
#> 1 1 e <dbl [1]>
#> 2 2 f <int [2]>
#> 3 3 g <int [3]>
#> 4 4 h <chr [1]>
|