Skip to content

Purpose of random_id() in make_cmd_transformer()? #294

@AlbertRapp

Description

@AlbertRapp

Preface

This post is not so much about a bug but rather a question about some (to me) unexpected behavior cli causes when calling readr::read_csv(). If this is not the best place to ask such a question (because, again, this is probably not a bug), please direct me to a more suitable place to ask my question. The original question can be found on stackoverflow (this also includes a reprex and an incomplete explanation of why this is happening).

Problem

I recently came to realize that using readr::read_csv() uses random numbers which of course is somewhat unexpected behavior for a function that simply reads data. On stackoverflow someone was kind enough to point out that readr::read_csv() uses the cli package whose function random_id() here uses random numbers. So, for completeness' sake, I would like to understand what the purpose of random_id() is.

Reprex from Stackoverflow (for completeness)

library(tidyverse)
set.seed(123)
rnorm(1)
# [1] -0.5604756

set.seed(123)
dat <- read.csv("data/titanic.csv")
rnorm(1)
# [1] -0.5604756

set.seed(123)
dat <- read_csv("data/titanic.csv")
rnorm(1)
#[1] 1.239496
Session Info
library(readr)
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                       
#>  version  R version 4.0.5 (2021-03-31)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  German_Germany.1252         
#>  ctype    German_Germany.1252         
#>  tz       Europe/Berlin               
#>  date     2021-06-10                  
#> 
#> - Packages -------------------------------------------------------------------
#>  package     * version     date       lib source                            
#>  cli           2.5.0       2021-04-26 [1] CRAN (R 4.0.3)                    
#>  crayon        1.4.1       2021-02-08 [1] CRAN (R 4.0.4)                    
#>  digest        0.6.27      2020-10-24 [1] CRAN (R 4.0.3)                    
#>  ellipsis      0.3.2       2021-04-29 [1] CRAN (R 4.0.3)                    
#>  evaluate      0.14        2019-05-28 [1] CRAN (R 4.0.3)                    
#>  fansi         0.5.0       2021-05-25 [1] CRAN (R 4.0.5)                    
#>  fastmap       1.1.0       2021-01-25 [1] CRAN (R 4.0.5)                    
#>  fs            1.5.0       2020-07-31 [1] CRAN (R 4.0.3)                    
#>  glue          1.4.2       2020-08-27 [1] CRAN (R 4.0.3)                    
#>  highr         0.9         2021-04-16 [1] CRAN (R 4.0.5)                    
#>  hms           1.0.0       2021-01-13 [1] CRAN (R 4.0.5)                    
#>  htmltools     0.5.1.9003  2021-05-07 [1] Github (rstudio/htmltools@e12171e)
#>  knitr         1.33        2021-04-24 [1] CRAN (R 4.0.5)                    
#>  lifecycle     1.0.0       2021-02-15 [1] CRAN (R 4.0.4)                    
#>  magrittr      2.0.1       2020-11-17 [1] CRAN (R 4.0.3)                    
#>  pillar        1.6.1       2021-05-16 [1] CRAN (R 4.0.5)                    
#>  pkgconfig     2.0.3       2019-09-22 [1] CRAN (R 4.0.3)                    
#>  ps            1.6.0       2021-02-28 [1] CRAN (R 4.0.5)                    
#>  R6            2.5.0       2020-10-28 [1] CRAN (R 4.0.3)                    
#>  readr       * 1.4.0       2020-10-05 [1] CRAN (R 4.0.5)                    
#>  reprex        2.0.0       2021-04-02 [1] CRAN (R 4.0.5)                    
#>  rlang         0.4.11.9000 2021-05-29 [1] Github (r-lib/rlang@7797cdf)      
#>  rmarkdown     2.8.1       2021-05-07 [1] Github (rstudio/rmarkdown@e98207f)
#>  rstudioapi    0.13        2020-11-12 [1] CRAN (R 4.0.3)                    
#>  sessioninfo   1.1.1       2018-11-05 [1] CRAN (R 4.0.3)                    
#>  stringi       1.5.3       2020-09-09 [1] CRAN (R 4.0.3)                    
#>  stringr       1.4.0       2019-02-10 [1] CRAN (R 4.0.3)                    
#>  tibble        3.1.2       2021-05-16 [1] CRAN (R 4.0.5)                    
#>  utf8          1.2.1       2021-03-12 [1] CRAN (R 4.0.3)                    
#>  vctrs         0.3.8       2021-04-29 [1] CRAN (R 4.0.3)                    
#>  withr         2.4.2       2021-04-18 [1] CRAN (R 4.0.5)                    
#>  xfun          0.22        2021-03-11 [1] CRAN (R 4.0.5)                    
#>  yaml          2.2.1       2020-02-01 [1] CRAN (R 4.0.3)                    
#> 
#> [1] C:/Users/Albert/Documents/R/win-library/4.0
#> [2] C:/Program Files/R/R-4.0.5/library

Created on 2021-06-10 by the reprex package (v2.0.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions