Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

label_parsed doesn't render the expression #2279

Closed
sahirbhatnagar opened this issue Oct 2, 2017 · 2 comments
Closed

label_parsed doesn't render the expression #2279

sahirbhatnagar opened this issue Oct 2, 2017 · 2 comments
Labels
bug an unexpected problem or unintended behavior facets 💎

Comments

@sahirbhatnagar
Copy link

This example from the help docs used to work, but doesn't anymore.

library(ggplot2)
mtcars$cyl2 <- factor(mtcars$cyl, labels = c("alpha", "beta", "gamma"))
p <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
p + facet_grid(. ~ cyl2, labeller = label_parsed)

Session info
devtools::session_info()
#> Session info -------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.4.1 (2017-06-30)
#>  system   x86_64, linux-gnu           
#>  ui       X11                         
#>  language en_US                       
#>  collate  en_US.UTF-8                 
#>  tz       Canada/Eastern              
#>  date     2017-10-02
#> Packages -----------------------------------------------------------------
#>  package    * version    date       source                          
#>  backports    1.1.0      2017-05-22 cran (@1.1.0)                   
#>  base       * 3.4.1      2017-07-08 local                           
#>  bitops       1.0-6      2013-08-17 CRAN (R 3.4.1)                  
#>  colorspace   1.3-2      2016-12-14 CRAN (R 3.4.1)                  
#>  compiler     3.4.1      2017-07-08 local                           
#>  datasets   * 3.4.1      2017-07-08 local                           
#>  devtools     1.13.3     2017-08-02 CRAN (R 3.4.1)                  
#>  digest       0.6.12     2017-01-27 CRAN (R 3.4.1)                  
#>  evaluate     0.10.1     2017-06-24 cran (@0.10.1)                  
#>  ggplot2    * 2.2.1.9000 2017-09-18 Github (hadley/ggplot2@c592e32) 
#>  graphics   * 3.4.1      2017-07-08 local                           
#>  grDevices  * 3.4.1      2017-07-08 local                           
#>  grid         3.4.1      2017-07-08 local                           
#>  gtable       0.2.0      2016-02-26 CRAN (R 3.4.1)                  
#>  htmltools    0.3.6      2017-04-28 cran (@0.3.6)                   
#>  knitr        1.17       2017-08-10 cran (@1.17)                    
#>  labeling     0.3        2014-08-23 CRAN (R 3.4.1)                  
#>  lazyeval     0.2.0      2016-06-12 CRAN (R 3.4.1)                  
#>  magrittr     1.5        2014-11-22 CRAN (R 3.4.1)                  
#>  memoise      1.1.0      2017-04-21 CRAN (R 3.4.1)                  
#>  methods    * 3.4.1      2017-07-08 local                           
#>  munsell      0.4.3      2016-02-13 CRAN (R 3.4.1)                  
#>  plyr         1.8.4      2016-06-08 CRAN (R 3.4.1)                  
#>  Rcpp         0.12.12    2017-07-15 CRAN (R 3.4.1)                  
#>  RCurl        1.95-4.8   2016-03-01 CRAN (R 3.4.1)                  
#>  reshape2     1.4.2      2016-10-22 CRAN (R 3.4.1)                  
#>  rlang        0.1.2      2017-08-09 CRAN (R 3.4.1)                  
#>  rmarkdown    1.6        2017-06-15 CRAN (R 3.4.1)                  
#>  rprojroot    1.2        2017-01-16 CRAN (R 3.4.1)                  
#>  scales       0.5.0.9000 2017-09-18 Github (hadley/scales@d767915)  
#>  stats      * 3.4.1      2017-07-08 local                           
#>  stringi      1.1.5      2017-04-07 CRAN (R 3.4.1)                  
#>  stringr      1.2.0      2017-02-18 CRAN (R 3.4.1)                  
#>  tibble       1.3.4      2017-08-22 CRAN (R 3.4.1)                  
#>  tools        3.4.1      2017-07-08 local                           
#>  utils      * 3.4.1      2017-07-08 local                           
#>  withr        2.0.0      2017-09-18 Github (jimhester/withr@d1f0957)
#>  XML          3.98-1.9   2017-06-19 CRAN (R 3.4.1)                  
#>  yaml         2.1.14     2016-11-12 cran (@2.1.14)
@hadley hadley added bug an unexpected problem or unintended behavior facets 💎 labels Oct 30, 2017
@hadley
Copy link
Member

hadley commented Oct 30, 2017

Seems to be a problem in title_spec. When the labeller yield expressions in build_strip(), need to pass label[[1]] instead of label to the textGrob.

@hadley
Copy link
Member

hadley commented Nov 1, 2017

And the base problem is that apply() indexes with [, not [[

mat <- matrix(1:4, nrow = 2)
lmt <- matrix(as.list(1:4), nrow = 2)

apply(mat, c(1,2), typeof)
#>      [,1]      [,2]     
#> [1,] "integer" "integer"
#> [2,] "integer" "integer"
apply(lmt, c(1,2), typeof)
#>      [,1]   [,2]  
#> [1,] "list" "list"
#> [2,] "list" "list"

@hadley hadley closed this as completed in bef2f38 Nov 1, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior facets 💎
Projects
None yet
Development

No branches or pull requests

2 participants