official example fails: as_tibble(as.list(1:3), .name_repair = "unique")

tibble
#1

Please help as below code fails even though taken from official source examples section of:

library(tibble)
as_tibble(as.list(1:3), .name_repair = "unique")

gives:
library(tibble)

as_tibble(as.list(1:3), .name_repair = "unique")

Error: Columns 1, 2, 3 must be named
Traceback:

  1. as_tibble(as.list(1:3), .name_repair = "unique")
  2. as_tibble.list(as.list(1:3), .name_repair = "unique")
  3. list_to_tibble(x, validate)
  4. check_tibble(x)
  5. invalid_df("must be named", x, which(bad_name))
  6. stopc(pluralise_msg("Column(s) ", vars), " ", pluralise(problem,
    . vars))
  7. abort(paste0(...))
0 Likes

#2

Can you check the version of tibble you are using.

I have no error on my side

library(tibble)
sessioninfo::package_info("tibble")
#>  package    * version date       lib source        
#>  assertthat   0.2.0   2017-04-11 [1] CRAN (R 3.5.1)
#>  cli          1.0.1   2018-09-25 [1] CRAN (R 3.5.1)
#>  crayon       1.3.4   2017-09-16 [1] CRAN (R 3.5.1)
#>  fansi        0.4.0   2018-10-05 [1] CRAN (R 3.5.1)
#>  pillar       1.3.1   2018-12-15 [1] CRAN (R 3.5.1)
#>  pkgconfig    2.0.2   2018-08-16 [1] CRAN (R 3.5.1)
#>  rlang        0.3.1   2019-01-08 [1] CRAN (R 3.5.2)
#>  tibble     * 2.0.1   2019-01-12 [1] CRAN (R 3.5.2)
#>  utf8         1.1.4   2018-05-24 [1] CRAN (R 3.5.1)
#> 
#> [1] C:/Users/chris/Documents/R/win-library/3.5
#> [2] C:/Program Files/R/R-3.5.1/library
as_tibble(as.list(1:3), .name_repair = "unique")
#> New names:
#> * `` -> `..1`
#> * `` -> `..2`
#> * `` -> `..3`
#> # A tibble: 1 x 3
#>     ..1   ..2   ..3
#>   <int> <int> <int>
#> 1     1     2     3

Created on 2019-02-10 by the reprex package (v0.2.1)

0 Likes

#3

What version of tibble are you running? It works for me:

library(tibble)

l <- list(x = 1:500, y = runif(500), z = 500:1)
df <- as_tibble(l)

m <- matrix(rnorm(50), ncol = 5)
colnames(m) <- c("a", "b", "c", "d", "e")
df <- as_tibble(m)

as_tibble(as.list(1:3), .name_repair = "unique")
#> New names:
#> * `` -> `..1`
#> * `` -> `..2`
#> * `` -> `..3`
#> # A tibble: 1 x 3
#>     ..1   ..2   ..3
#>   <int> <int> <int>
#> 1     1     2     3

Created on 2019-02-10 by the reprex package (v0.2.1.9000)

1 Like

#4

Hi, thanks for your help. I am running Tibble 1.4.2 which is what I get using Anaconda. I see that anew version 2.01 is available. do you know when that will make it onto Anaconda plz? I seem to run into issues using anaconda with out of date packages.

0 Likes

#5

You are going to have a lot of this kind of issues working with R and Rstudio in Anaconda, Do you have any particular reason for not using the regular stand alone versions?

0 Likes

#6

I find the conda gui helpful managing multiple environments in python and R but can appreciate fully advice from multiple sources to use standalone.
I just tried updating Tibble in my conda install of Rstudio and it failed stating that there were packages in use even though I'd just restarted Rstudio, many dependent packages did seem to update but not Tibble.

0 Likes

#7

I would follow @andresrcs advice and not use rstudio and R within Anaconda.

But if you must, you may use other channels than the R one, like conda force.
It seems there is an update there :
https://anaconda.org/conda-forge/r-tibble

Anyway, there still will be delay between release in cran and in conda. You should use a R distrib that let you use CRAN I think.

1 Like

#8

If not, you should definitely pay attention to the docs built into the packages themselves (since they'll always be in sync with whatever version you have installed. For example, if you have the tibble package loaded, you can run ?as_tibble, and get the examples that work with your associated version.

1 Like

closed #9

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

0 Likes