Skip to content

glue object drops "glue" class when subsetted #66

@austensen

Description

@austensen

I noticed that using glue in dplyr::if_else or dplyr::case_when raised errors that the objects aren't of the same class. In tidyverse/dplyr#3109 Hadley said "this looks like a glue issue - it shouldn't dropping the class when subsetted."

# devtools::install_github("tidyverse/glue")

library(glue)

dplyr::if_else(TRUE, glue("foo"), glue("bar"))
#> Error: `true` must be character, not glue/character

dplyr::case_when(
  TRUE ~ glue("foo")
)
#> Error: must be character, not glue/character



foo <- glue::glue("{1:3}")

class(foo)
#> [1] "glue"      "character"

class(foo[[1]])
#> [1] "character"
Session info
devtools::session_info()
#> Session info -------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.4.2 (2017-09-28)
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  English_United States.1252  
#>  tz       America/New_York            
#>  date     2017-11-05
#> Packages -----------------------------------------------------------------
#>  package    * version    date       source                          
#>  assertthat   0.2.0      2017-04-11 CRAN (R 3.4.0)                  
#>  backports    1.1.0      2017-05-22 CRAN (R 3.4.0)                  
#>  base       * 3.4.2      2017-09-28 local                           
#>  bindr        0.1        2016-11-13 CRAN (R 3.4.0)                  
#>  bindrcpp     0.2        2017-06-17 CRAN (R 3.4.0)                  
#>  compiler     3.4.2      2017-09-28 local                           
#>  datasets   * 3.4.2      2017-09-28 local                           
#>  devtools     1.13.3     2017-08-02 CRAN (R 3.4.2)                  
#>  digest       0.6.12     2017-01-27 CRAN (R 3.4.0)                  
#>  dplyr        0.7.4      2017-09-28 CRAN (R 3.4.2)                  
#>  evaluate     0.10       2016-10-11 CRAN (R 3.4.0)                  
#>  glue       * 1.2.0.9000 2017-11-05 Github (tidyverse/glue@8ad62f1) 
#>  graphics   * 3.4.2      2017-09-28 local                           
#>  grDevices  * 3.4.2      2017-09-28 local                           
#>  htmltools    0.3.6      2017-04-28 CRAN (R 3.4.0)                  
#>  knitr        1.17       2017-08-10 CRAN (R 3.4.1)                  
#>  magrittr     1.5        2014-11-22 CRAN (R 3.4.0)                  
#>  memoise      1.1.0      2017-04-21 CRAN (R 3.4.0)                  
#>  methods    * 3.4.2      2017-09-28 local                           
#>  pkgconfig    2.0.1      2017-03-21 CRAN (R 3.4.0)                  
#>  R6           2.2.2      2017-06-17 CRAN (R 3.4.0)                  
#>  Rcpp         0.12.13    2017-09-28 CRAN (R 3.4.2)                  
#>  rlang        0.1.2      2017-08-09 CRAN (R 3.4.1)                  
#>  rmarkdown    1.6        2017-06-15 CRAN (R 3.4.0)                  
#>  rprojroot    1.2        2017-01-16 CRAN (R 3.4.0)                  
#>  stats      * 3.4.2      2017-09-28 local                           
#>  stringi      1.1.5      2017-04-07 CRAN (R 3.4.0)                  
#>  stringr      1.2.0      2017-02-18 CRAN (R 3.4.0)                  
#>  tibble       1.3.4      2017-08-22 CRAN (R 3.4.1)                  
#>  tools        3.4.2      2017-09-28 local                           
#>  utils      * 3.4.2      2017-09-28 local                           
#>  withr        2.0.0      2017-08-22 Github (jimhester/withr@0c4a86d)
#>  yaml         2.1.14     2016-11-12 CRAN (R 3.4.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions