Is `stat_qq_line` in ggplot2 2.2.1 (CRAN latest)?

So the docs say that there exists a function called stat_qq_line:

And I can see from whence that originated:

Holla at Nick Solomon and Kara Woo!

But if I try to use stat_qq_line I get an error:

library(ggplot2)
df <- data.frame(y = rt(200, df = 5))
p <- ggplot(df, aes(sample = y))
p + stat_qq() + stat_qq_line()

# Error in stat_qq_line() : could not find function "stat_qq_line"

I can tell my RStudio.cloud session is running ggplot 2.2.1 (CRAN Latest I think). Should I expect to see stat_qq_line in there? How can I tell which version of ggplot incorporated stat_qq_line? Since Karen Woo committed the change over a year ago, I would expect it to be in the current version. But it seems it isn't.

Thanks for the help!

stat_qq_line() is in the development version of ggplot2, which is scheduled to be submitted to CRAN next month. In the meantime you can get it with devtools::install_github("tidyverse/ggplot2").

4 Likes

Thanks @karawoo! As a user not at all familiar with the ggplot2 development process (other than searching github comments) Is there a way I could have figured this out without sounding the bat signal?

1 Like

and my apologies for totally borking your name. Sorry Kara. :frowning:

No worries :slightly_smiling_face:

The NEWS.md file in the GitHub repo has a list of all user-facing changes by version, so that's a good place to look. Otherwise I think the only way is to compare the date of the last CRAN release to the date the pull request was merged.

2 Likes

that makes total sense. Thank you.

It's in the works. The plan is to have the primary pkgdown site with the documentation for the latest CRAN release of a package, and a dev. site with the documentation for the package in development (not indexed for search, etc.) – so, basically, you, “a user not at all familiar with the…development process”, won't be led astray by peeks of what's in the pipeline in outside of the CRAN version.

We're working out the process atm (them's the breaks of FOSS, since pkgdown is, itself, in active development), but Jenny has a system running for usethis you can take a look at (screenshots of the reference page, bc index has installation instructions for CRAN and devtools, which might change):

CRAN usethis Automate Package and Project Setup • usethis

dev usethis Automate Package and Project Setup • usethis

Currently there isn't an easy way to navigate between them without knowing the URL, due to the fact that things only got this far two days ago:

1 Like

Very sweet! I figured there "has to be a better way" than must me loading different versions and seeing what works where :wink:

Sounds like a great idea to break out the docs to a dev and CRAN version. That could really help!

1 Like

Yeah, hopefully there's an easy(ish) workflow for this (as one might imagine, we don't do full-blown site rebuilds for every update – though a new geom is a good example for a case_when() it'd be worth doing so for a dev site), otherwise the plan would be to have the pkgdown sites reflect the latest release version of the package to avoid what you just went through.

1 Like

your solution already sounds solid to me. I noticed that in Pandas and some other FLOSS projects, the docs have a version number on every page. I've found that helpful. Also helps because I can Google some function name and a version number and get the the docs for that feature as of a given version. The downside is that sometimes I search for a function and I get the docs from an older version. So there's always trade-offs.

This makes me think about the target audience for docs is not only a user, but Google who then directs the user.

1 Like

Yeah, as it turns out, the vast majority of users run what's on CRAN, which makes that an easier decision. There's also always the tried and true method built right into R! Your .Rd files will always reflect whatever version you have installed, so (in addition to getting the reference for a given function with ?foo) help(package = "ggplot2") will bring you to the index of documentation for said version.

3 Likes

Hi Kara,

I try this,

devtools::install_github("tidyverse/ggplot2")

But when I library ggplot2, I get error message,

Error: package or namespace load failed for ‘ggplot2’ in get(Info[i, 1], envir = env): lazy-load database '/Users/JiaxiangLi/Library/R/3.4/library/ggplot2/R/ggplot2.rdb' is corrupt

I feel it doesn't work because of my R version?

Here is my session info.

R version 3.4.4 (2018-03-15)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] wavelets_0.3-0 optparse_1.4.4

loaded via a namespace (and not attached):
 [1] nlme_3.1-131.1      lubridate_1.7.4     devtools_1.13.2    
 [4] httr_1.3.1          dimRed_0.1.0        numDeriv_2016.8-1  
 [7] tools_3.4.4         dfoptim_2018.2-1    R6_2.2.2           
[10] rpart_4.1-13        DBI_0.8             lazyeval_0.2.1     
[13] colorspace_1.3-2    nnet_7.3-12         withr_2.1.2        
[16] Rvmmin_2017-7.18    tidyselect_0.2.4    monmlp_1.1.5       
[19] mnormt_1.5-5        curl_2.6            git2r_0.18.0       
[22] compiler_3.4.4      scales_0.5.0        optextras_2016-8.8 
[25] sfsmisc_1.1-2       DEoptimR_1.0-8      psych_1.8.3.3      
[28] robustbase_0.92-8   quadprog_1.5-5      digest_0.6.12      
[31] stringr_1.3.0       foreign_0.8-69      minqa_1.2.4        
[34] pkgconfig_2.0.1     dbplyr_1.2.1        rlang_0.2.1        
[37] ddalpha_1.3.2       rstudioapi_0.7      pryr_0.1.4         
[40] bindr_0.1           svUnit_0.7-12       jsonlite_1.5       
[43] dplyr_0.7.4         ModelMetrics_1.1.0  magrittr_1.5       
[46] causalTree_0.0      Matrix_1.2-12       Rcpp_0.12.16       
[49] munsell_0.4.3       abind_1.4-5         ucminf_1.1-4       
[52] stringi_1.1.7       yaml_2.1.18         MASS_7.3-49        
[55] BB_2014.10-1        plyr_1.8.4          recipes_0.1.2      
[58] grid_3.4.4          parallel_3.4.4      remedy_0.0.0.9600  
[61] lattice_0.20-35     splines_3.4.4       knitr_1.20         
[64] pillar_1.2.1        reshape2_1.4.3      codetools_0.2-15   
[67] stats4_3.4.4        CVST_0.2-1          magic_1.5-8        
[70] glue_1.2.0          data.table_1.10.4-3 foreach_1.4.3      
[73] gtable_0.2.0        getopt_1.20.2       purrr_0.2.4        
[76] Rcgmin_2013-2.21    tidyr_0.8.0         kernlab_0.9-25     
[79] assertthat_0.2.0    DRR_0.0.3           gower_0.1.2        
[82] prodlim_1.6.1       broom_0.4.3         class_7.3-14       
[85] survival_2.41-3     geometry_0.3-6      timeDate_3043.102  
[88] RcppRoll_0.2.2      tibble_1.4.2        optimx_2013.8.7    
[91] iterators_1.0.8     memoise_1.1.0       setRNG_2013.9-1    
[94] bindrcpp_0.2        lava_1.6.1          caret_6.0-79       
[97] ipred_0.9-6 

In my experience, that problem can sometimes be solved by either:

  • Restarting your R session (in RStudio, look under the Sesson menu) — try this first!
  • Removing the problem package completely (here, try remove.packages("ggplot2") ) and reinstalling from a fresh R session

Does the problem persist after trying any of these steps?

Hi, the problem is fixed but new problem comes ...

Here is my logging data when I am downloading the package.

Downloading GitHub repo tidyverse/ggplot2@master
from URL https://api.github.com/repos/tidyverse/ggplot2/zipball/master
Installing ggplot2
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file  \
  --no-environ --no-save --no-restore --quiet CMD INSTALL  \
  '/private/var/folders/w9/1mk575815rbdx8bp5k3j132w0000gp/T/RtmpvAdIZu/devtools424c1cb55854/tidyverse-ggplot2-cc48035'  \
  --library='/Users/JiaxiangLi/Library/R/3.4/library'  \
  --install-tests 

* installing *source* package ‘ggplot2’ ...
** R
** data
*** moving datasets to lazyload DB
** inst
** tests
** preparing package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (ggplot2)

And here is the new problem, related to package caret, when I run library(ggplot2).

Error in value[[3L]](cond) : Package ‘ggplot2’ version 2.2.1 cannot be unloaded: Error in unloadNamespace(package) : namespace ‘ggplot2’ is imported by ‘caret’ so cannot be unloaded

Need I do something for ‘caret’?

It looks like your installation of ggplot2 was successful. :raised_hands:

Did you restart R both before and after installing? Trying to install and load new packages when you have other packages loaded that depend on those packages (or depend on packages that depend on those packages...) often causes problems.

Do you see this error if you follow these steps?

  1. Restart R (Session menu in RStudio)
  2. Run:
    library("ggplot2")
    library("caret")
    

Hi, thanks for your help. It works !!!

library("ggplot2")
library("caret")
df <- data.frame(y = rt(200, df = 5))
p <- ggplot(df, aes(sample = y))
p + stat_qq() + stat_qq_line()
ggsave("stat_qq.png")

1 Like

I did this but now my ggplot2 is broken with error:

ERROR: dependency 'rlang' is not available for package 'ggplot2'

have you tried installing the rlang package? If that doesn't work, try the dev version of rlang

devtools::install_github("r-lib/rlang")

I tried that but I get error:

  • installing source package 'rlang' ...
    Warning in system("sh ./configure.win") : 'sh' not found
    ERROR: configuration failed for package 'rlang'

it looks like you may not have Rtools installed for compiling and building from source on windows. Installers here:
https://cran.r-project.org/bin/windows/Rtools/index.html