direct.label error : Even directlabels manual example is not working

358 views
Skip to first unread message

John Kane

unread,
Jan 22, 2016, 2:59:17 PM1/22/16
to ggplot2
I have encountered a problem with an old script using direct.label but it seems more than just an out-of-date script.

I tried to run the gqplot example from the directlabels manual and it did not work. The lattice example did and I have no idea what the error message is trying to tell me.

Error in switch(geom, density = "top.bumptwice", line = { :
  EXPR must be a length 1 vector

If I try using geom_dl example from the manual I get a different error message but I am still clueless.

Error in eval(expr, envir, enclos) : could not find function "eval"


I updated all packages last week IIRC so I was wondering if I have an incompatibility?

Toy example:

mdat1  <-  structure(list(tmonth = c(4L, 5L, 6L, 7L, 8L, 9L, 10L, 4L, 5L,
6L, 7L, 8L, 9L, 10L, 4L, 5L, 6L, 7L, 8L, 9L, 10L), variable = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 3L, 3L, 3L), .Label = c("nsw", "qld", "vic"), class = "factor"),
    value = c(2L, 6L, 5L, 2L, 1L, 5L, 6L, 6L, 5L, 8L, 4L, 6L,
    5L, 4L, 9L, 2L, 4L, 6L, 8L, 7L, 5L)), row.names = c(NA, -21L
), .Names = c("tmonth", "variable", "value"), class = "data.frame")


library(ggplot2)
library(reshape2)
library(directlabels)

p  <-  ggplot(mdat1, aes(tmonth, value, colour = variable)) + geom_line()
print(direct.label(p))

sessionInfo()

R version 3.2.3 (2015-12-10)
Platform: i686-pc-linux-gnu (32-bit)
Running under: Ubuntu 14.04.3 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C             
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8   
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8  
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                
 [9] LC_ADDRESS=C               LC_TELEPHONE=C           
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C      

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods 
[8] base    

other attached packages:
[1] reshape2_1.4.1         directlabels_2013.6.15 quadprog_1.5-5       
[4] ggplot2_2.0.0        

loaded via a namespace (and not attached):
 [1] labeling_0.3     colorspace_1.2-6 scales_0.3.0     magrittr_1.5   
 [5] plyr_1.8.3.9000  tools_3.2.3      gtable_0.1.2     Rcpp_0.12.2    
 [9] stringi_1.0-1    digest_0.6.8     stringr_1.0.0    munsell_0.4.2  

Ista Zahn

unread,
Jan 22, 2016, 3:12:24 PM1/22/16
to John Kane, ggplot2
Hi John,

Your sessionInfo() says you have directlabels version 2013.6.15.
Updating to the most recent release should work (it does for me).

Best,
Ista
> --
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ggplot2+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Brandon Hurr

unread,
Jan 22, 2016, 3:25:34 PM1/22/16
to Ista Zahn, John Kane, ggplot2
Ista and John, 

I was less lucky. I unloaded everything extra and tried again with same results.  

p  <-  ggplot(mdat1, aes(tmonth, value, colour = variable)) + geom_line() 
print(direct.label(p))
Error in switch(geom, density = "top.bumptwice", line = { : 
  EXPR must be a length 1 vector

devtools::session_info()
Session info --------------------------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.2.3 (2015-12-10)
 system   x86_64, darwin13.4.0        
 ui       AQUA                        
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       America/Los_Angeles         
 date     2016-01-22                  

Packages ------------------------------------------------------------------------------------------------------------------------------
 package      * version     date       source                              
 assertthat     0.1         2013-12-06 CRAN (R 3.2.0)                      
 colorspace     1.2-6       2015-03-11 CRAN (R 3.2.0)                      
 DBI            0.3.1       2014-09-24 CRAN (R 3.2.0)                      
 devtools       1.9.1.9000  2016-01-01 Github (hadley/devtools@8ad299f)    
 digest         0.6.8       2014-12-31 CRAN (R 3.2.0)                      
 directlabels * 2015.6.17   2015-11-19 Github (hadley/directlabels@c098c2d)
 dplyr        * 0.4.3       2015-09-01 CRAN (R 3.2.0)                      
 ggplot2      * 2.0.0.9001  2016-01-05 Github (hadley/ggplot2@c3f38ee)     
 gridExtra    * 2.0.0       2015-07-14 CRAN (R 3.2.0)                      
 gtable         0.1.2       2012-12-05 CRAN (R 3.2.0)                      
 lazyeval       0.1.10.9000 2015-05-26 Github (hadley/lazyeval@ecb8dc0)    
 magrittr     * 1.5         2014-11-22 CRAN (R 3.2.0)                      
 memoise        0.2.1       2014-04-22 CRAN (R 3.2.0)                      
 munsell        0.4.2       2013-07-11 CRAN (R 3.2.0)                      
 plyr         * 1.8.3.9000  2015-10-16 Github (hadley/plyr@9d8294e)        
 quadprog       1.5-5       2013-04-17 CRAN (R 3.2.0)                      
 R6             2.1.1       2015-08-19 CRAN (R 3.2.0)                      
 Rcpp           0.12.2      2015-11-15 CRAN (R 3.2.2)                      
 readxl       * 0.1.0.9000  2015-11-02 Github (hadley/readxl@7c7f66b)      
 reshape2     * 1.4.1       2014-12-06 CRAN (R 3.2.0)                      
 scales         0.3.0.9000  2015-11-19 Github (hadley/scales@7fc502c)      
 stringi        1.0-1       2015-10-22 CRAN (R 3.2.0)                      
 stringr        1.0.0       2015-04-30 CRAN (R 3.2.0)                      
 tidyr        * 0.3.1.9000  2016-01-05 Github (hadley/tidyr@7a4f82c)    

Hadley Wickham

unread,
Jan 25, 2016, 10:48:44 AM1/25/16
to Brandon Hurr, Ista Zahn, John Kane, ggplot2
You might try using geom_dl() instead.
Hadley
http://had.co.nz/

John Kane

unread,
Jan 26, 2016, 7:11:34 AM1/26/16
to Hadley Wickham, Brandon Hurr, Ista Zahn, ggplot2
Thanks Hadley,
I had neglected to say that I had tried geom_dl as well. 

BTW, I have changed my code to use geom_dl anyway. Much cleaner way to go.
--
John Kane
Kingston ON Canada
Reply all
Reply to author
Forward
0 new messages