CRAN notes that files cannot be checked without ‘pandoc’ being installed - r

In doing final checks on a CRAN package submission, this NOTE comes up:
* checking top-level files ... NOTE
Files ‘README.md’ or ‘NEWS.md’ cannot be checked without ‘pandoc’ being installed.
However, pandoc is definitely installed as I use it regularly, and this package makes frequent use of it in documentation using pkgdown.
> rmarkdown::pandoc_available()
[1] TRUE
> rmarkdown::pandoc_version()
[1] ‘1.19.2.1’
I want to avoid installing pandoc from source because the latest version of pandoc supercedes the version installed with other R packages and causes weird output.
There is a similar question from a few years back but the solutions there are to either:
Install pandoc from source or via the installr package, whereas I already have pandoc installed; and,
Place the two files into .Rbuildignore, however both should be accepted with CRAN submissions now.
This note only comes up when checked using devtools::release() and when using devtools::check(check_version = TRUE), which otherwise passes with no warnings or notes.
The RStudio install of Pandoc:
Sys.getenv('RSTUDIO_PANDOC')
[1] "/Applications/RStudio.app/Contents/MacOS/pandoc"
Which I had previously exported to my ~/.bash_profile:
export PATH="$PATH:/Applications/Rstudio.app/Contents/MacOS/pandoc"
Any ideas?
> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.2
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_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] cancensus_0.1.6
loaded via a namespace (and not attached):
[1] Rcpp_0.12.14 rstudioapi_0.7 knitr_1.17 bindr_0.1
[5] xml2_1.1.1 magrittr_1.5 roxygen2_6.0.1 devtools_1.13.4
[9] R6_2.2.2 rlang_0.1.6 httr_1.3.1 stringr_1.2.0
[13] dplyr_0.7.4 tools_3.4.3 hunspell_2.9 git2r_0.20.0
[17] withr_2.1.1 htmltools_0.3.6 rversions_1.0.3 commonmark_1.4
[21] rprojroot_1.2 yaml_2.1.14 digest_0.6.13 assertthat_0.2.0
[25] tibble_1.3.4 crayon_1.3.4 bindrcpp_0.2 curl_3.1
[29] evaluate_0.10.1 memoise_1.1.0 glue_1.2.0 rmarkdown_1.8
[33] stringi_1.1.5 compiler_3.4.3 backports_1.1.0 desc_1.1.1
[37] jsonlite_1.5 pkgconfig_2.0.1

This happens because devtools::release calls devtools::check with check_version = TRUE.
You can also run devtools::check(check_version = TRUE) to trigger the same note.
I think for this part you would need pandoc on your PATH.
(indeed, after adding the existing ...\RStudio\bin\pandoc to my PATH the note is gone)

This question appears to be a duplicate.
Currently no accepted solution at the above linked Q. However, #hrbrmster's suggested solution in that thread: adding the README.md and NEWS.md to the .Rbuildignore remove the NOTES for me.
Current .RBuildignore contents
^pkg_name_here\.Rproj$
^\.Rproj\.user$
^cran-comments\.md$
^CODE_OF_CONDUCT\.md$
^README\.md$
^NEWS\.md$

Related

Use older version of ggplot in R script file

I have ggplot2 3.4.0 installed on Ubuntu 22.04, but for some reasons I would like to use older version ggplot2 3.3.6.
library(ggplot2, lib.loc="~/R/ggplot336/")
I worked fine when I started with a clean script file. However, when I use an existing script file like:
library(ggplot2, lib.loc="~/R/ggplot336/")
ggimage::geom_image()
I got the following error massage:
Error in value[3L] :
Package ‘ggplot2’ version 3.4.0 cannot be unloaded:
Error in unloadNamespace(package) : namespace ‘ggplot2’ is imported by ‘ggfun’, ‘ggplotify’, ‘ggimage’ so cannot be unloaded
Edit
Fresh start Rstudio
Open my R script file with following 3 lines:
sessionInfo()
library(ggplot2, lib.loc="~/R/ggplot336/")
ggimage::geom_image()
When I run the first line, sessionInfo() before doing anything else. We can see ggplot2_3.4.0 there. Could this be a Rstudio feature or an issue?
R version 4.2.2 Patched (2022-11-10 r83330)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.1 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
locale:
[1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C LC_TIME=en_AU.UTF-8
[4] LC_COLLATE=en_AU.UTF-8 LC_MONETARY=en_AU.UTF-8 LC_MESSAGES=en_AU.UTF-8
[7] LC_PAPER=en_AU.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] Rcpp_1.0.9 highr_0.9 pillar_1.8.1 compiler_4.2.2
[5] R.utils_2.12.2 R.methodsS3_1.8.2 yulab.utils_0.0.5 tools_4.2.2
[9] digest_0.6.30 evaluate_0.18 jsonlite_1.8.3 lifecycle_1.0.3
[13] tibble_3.1.8 gtable_0.3.1 ggimage_0.3.1 R.cache_0.16.0
[17] pkgconfig_2.0.3 rlang_1.0.6 reprex_2.0.2 DBI_1.1.3
[21] cli_3.4.1 ggplotify_0.1.0 rstudioapi_0.14 magick_2.7.3
[25] yaml_2.3.6 xfun_0.35 fastmap_1.1.0 knitr_1.41
[29] withr_2.5.0 dplyr_1.0.10 styler_1.8.1 generics_0.1.3
[33] vctrs_0.5.1 fs_1.5.2 gridGraphics_0.5-1 grid_4.2.2
[37] tidyselect_1.2.0 glue_1.6.2 R6_2.5.1 processx_3.8.0
[41] fansi_1.0.3 rmarkdown_2.18 clipr_0.8.0 callr_3.7.3
[45] ggplot2_3.4.0 purrr_0.3.5 magrittr_2.0.3 ps_1.7.2
[49] htmltools_0.5.3 scales_1.2.1 assertthat_0.2.1 colorspace_2.0-3
[53] utf8_1.2.2 munsell_0.5.0 ggfun_0.0.9 R.oo_1.25.0
It looks like R studio is loading in all of the previous libraries from a previous session. Maybe something leftover in .RData or .Rhistory. A fresh start of R should have far few loaded libraries.
Here is my fresh start:
sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.6.1
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/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 base
loaded via a namespace (and not attached):
[1] compiler_4.2.2 tools_4.2.2
In Rstudio's preference you should see this screen:
I would try unchecking all of the boxes and then quit and restart Rstudio to see if that clears up the problem.
After some experiments, I kind of worked out the problem. Since this has consumed so much time of my time, I thought this could be helpful to others.
The problem is :: (double colon) with packages using ggplot2, such as ggimage in my example. It appears that RStudio automatically load some dependent packages when a script file is open. One way to fix this problem for my work now is to remove ::, but use library() then function (geom_image) instead.
This fixed my problem but I still don't understand why RStudio behaves this way.
If :: (double colon) is necessary, comment lines containing ::, then after loading older version of ggplot2, uncomment those lines. A little awkward, but it works for me.

save_kable does not work after installing R v4.0.2

I have successfully used save_kable() from kableExtra to export latex tables into *.png before. However, after updating R to the version 4.0.2, save_kable always ends with R fatal error (no specific error message is shown, the session is just aborted). I installed a clean version o R 3.6.3 and everything works fine again.
Next, I re-installed MikTEX, but this does not seem to be the problem because R Markdown can knit a .pdf file without an issue (in the 4.0.2 version). Also, using save_kable with "html" options works fine and exports the table into .png. The problem seems to be specific for latex.
Looking at sessionInfo(), the only difference is that R 3.6.3 automatically loads the 'magick' package, while R 4.0.2 does not. However, loading the magick package manually in the latter R version does not solve the problem. Then, of course, the sessions differ in the "compiler" package versions. Maybe this is the source of the problem?
Any help would be much appreciated. The problem can be reproduced with minimal code such as
kable(mtcars, "latex") %>% save_kable("test.png")
Here is the sessionInfo
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)
Matrix products: default
Random number generation:
RNG: Mersenne-Twister
Normal: Inversion
Sample: Rounding
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] magick_2.4.0 kableExtra_1.1.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 rstudioapi_0.11 knitr_1.29 xml2_1.3.2 magrittr_1.5
[6] hms_0.5.3 rvest_0.3.5 munsell_0.5.0 viridisLite_0.3.0 colorspace_1.4-1
[11] R6_2.4.1 rlang_0.4.7 stringr_1.4.0 httr_1.4.1 tools_4.0.2
[16] webshot_0.5.2 xfun_0.15 htmltools_0.5.0 ellipsis_0.3.1 digest_0.6.25
[21] tibble_3.0.3 lifecycle_0.2.0 crayon_1.3.4 readr_1.3.1 vctrs_0.3.2
[26] glue_1.4.1 evaluate_0.14 rmarkdown_2.3 stringi_1.4.6 compiler_4.0.2
[31] pillar_1.4.6 scales_1.1.1 pkgconfig_2.0.3
This seems to be a windows specific problem. I actually just asked a recent question here
kableExtra HTML styling in Rmarkdown and kable_save()
Some of the things I have seen mentioned as potential fixes are listed there such as updating ghostscript, not using tinytext, updating some latex packages including 'standalone', and editing the policy.xls document in ImageMagick ImageMagick security policy 'PDF' blocking conversion.
None of these worked for me and I get the same crashing issues the second I try to kable_save a latex format into png. However, some other Windows users have found success with the steps above so maybe try that out and see how it goes.

Autoplot error when using ggcyto (Bioconductor) package: 'ggplot.data.frame' not found

I am running R-3.5.0 and RStudio 1.1.423 on Windows 7. I had to use our corporate installer for both programs, so I did not download the installer .exe files and am also limited in having the most recent version of the software.
I am trying to use the Bioconductor project FlowCore and ggcyto package to plot flow cytometry events. In the beginning this worked quite well, but recently (and I have no idea if I even changed anything) I cannot plot my flowframes using autoplot. Here's the example from the ggcyto documentation:
library(flowCore)
library(ggcyto)
data(GvHD)
fs <- GvHD[subset(pData(GvHD), Patient %in%5:7 & Visit %in% c(5:6))[["name"]]]
autoplot(fs, x = "SSC-H")
which results in
Error in get(name, envir = asNamespace(pkg), inherits = FALSE) :
object 'ggplot.data.frame' not found
I noticed one strange thing: I cannot update the stringi package to the latest (I believe 1.2.3) version, only to 1.1.7.
It is suggested in this thread: R gives strange error with ggplot2 expression: object 'rversion' not found
that it is an RStudio problem. However, when running the same code in the R console without RStudio, I get the same error message.
Any help is greatly appreciated!
I found the source of the problem. Apparently I must have updated my packages and the latest ggplot2 release does not interact well with the ggcyto package.
A downgrade of ggplot2 to version 2.2.1 fixed it.
I ran into the exact same problem today running the most up-to-date R binaries and Rstudio version. I ended up using the package "flowViz" and the function: flowplot() to receive essentially the same result (just without the binning) as the autoplot() function of the "ggcyto" package utilized in the FlowCore Vignette. I hope this helps.
I am happy to report that this no longer fails in more recent R/BioC environments such as:
sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)
Matrix products: default
BLAS: /n/apps/CentOS7/install/r-3.5.2/lib64/R/lib/libRblas.so
LAPACK: /n/apps/CentOS7/install/r-3.5.2/lib64/R/lib/libRlapack.so
locale:
[1] C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggcyto_1.10.2 flowWorkspace_3.30.2 ncdfFlow_2.28.1 BH_1.69.0-1 RcppArmadillo_0.9.400.3.0 ggplot2_3.1.1 flowCore_1.48.1 usethis_1.5.0 devtools_2.0.2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.1 mvtnorm_1.0-10 lattice_0.20-38 corpcor_1.6.9 prettyunits_1.0.2 ps_1.3.0 assertthat_0.2.1 rprojroot_1.3-2 digest_0.6.18 R6_2.4.0 plyr_1.8.4 backports_1.1.4 stats4_3.5.2 pcaPP_1.9-73 pillar_1.4.0 zlibbioc_1.28.0 rlang_0.3.4 lazyeval_0.2.2 data.table_1.12.2 Rgraphviz_2.26.0 callr_3.2.0 hexbin_1.27.3 labeling_0.3 desc_1.2.0 stringr_1.4.0 munsell_0.5.0 compiler_3.5.2 pkgconfig_2.0.2 BiocGenerics_0.28.0
[30] pkgbuild_1.0.3 IDPmisc_1.1.19 tidyselect_0.2.5 gridExtra_2.3 tibble_2.1.1 matrixStats_0.54.0 XML_3.98-1.19 flowViz_1.46.1 rrcov_1.4-7 crayon_1.3.4 dplyr_0.8.1 withr_2.1.2 MASS_7.3-51.4 grid_3.5.2 gtable_0.3.0 magrittr_1.5 scales_1.0.0 graph_1.60.0 KernSmooth_2.23-15 stringi_1.4.3 cli_1.1.0 fs_1.3.1 remotes_2.0.4 testthat_2.1.1 latticeExtra_0.6-28 robustbase_0.93-5 RColorBrewer_1.1-2 tools_3.5.2 Biobase_2.42.0
[59] glue_1.3.1 DEoptimR_1.0-8 purrr_0.3.2 processx_3.3.1 pkgload_1.0.2 parallel_3.5.2 colorspace_1.4-1 cluster_2.0.9 sessioninfo_1.1.1 memoise_1.1.0

Error in loading package SASxport: object ‘label<-.data.frame’ is not exported by 'namespace:Hmisc'

I'm trying to read data in the XPT format into R (the format can be found for example in the NHANES data). I found two functions doing this:
library("Hmisc")
sasxport.get("C:/path/file.XPT")
and
library("SASxport")
read.xport("C:/path/file.XPT")
The sasxport.get works, so I'm basically fine, but still inquisitive enough to understand (and solve) the following error: after the installation of the SASxport package, I cannot load it. When I run library("SASxport"), I get the error message:
Error: package or namespace load failed for ‘SASxport’:
object ‘label<-.data.frame’ is not exported by 'namespace:Hmisc'
Adopting this suggestion, I also ran
remove.packages(c("SASxport", "Hmisc"))
install.packages('Hmisc', dependencies = TRUE)
install.packages('SASxport', dependencies = TRUE)
what did not change the error message.
This is my sessionInfo():
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] Hmisc_4.1-1 ggplot2_2.2.1 Formula_1.2-2 survival_2.41-3 lattice_0.20-35
loaded via a namespace (and not attached):
[1] Rcpp_0.12.14 pillar_1.0.1 compiler_3.4.3 RColorBrewer_1.1-2 plyr_1.8.4
[6] base64enc_0.1-3 iterators_1.0.9 tools_3.4.3 rpart_4.1-11 digest_0.6.13
[11] tibble_1.4.1 gtable_0.2.0 htmlTable_1.11.1 checkmate_1.8.5 rlang_0.1.6
[16] icenReg_2.0.7 Matrix_1.2-12 foreach_1.4.4 rstudioapi_0.7 yaml_2.1.16
[21] gridExtra_2.3 coda_0.19-1 stringr_1.2.0 cluster_2.0.6 knitr_1.18
[26] htmlwidgets_0.9 grid_3.4.3 nnet_7.3-12 data.table_1.10.4-3 foreign_0.8-69
[31] latticeExtra_0.6-28 magrittr_1.5 scales_0.5.0 backports_1.1.2 codetools_0.2-15
[36] htmltools_0.3.6 splines_3.4.3 colorspace_1.3-2 stringi_1.1.6 acepack_1.4.1
[41] lazyeval_0.2.1 munsell_0.4.3
The last update of SASxport happend nearly two years ago (2016-03-11). So the Hmisc package it imports might have changed in the meantime. Looking up the Hmisc archive I found the version number on 2016-03-11 to be 3.17-2. So installing this version fixes the problem:
library("devtools")
install_version("Hmisc", version = "3.17-2")
Two reasons speak against using SASxport in this case:
You need to use a old version of a package which might happer your work in later steps.
SASxport needs Hmisc for a task that Hmisc can do already by itself, so SASxport is expendable when reading in XPT files.

Images not showing in R notenook (nb.html file)

When I knit to HTML, images show up fine in the .html file, but not the .nb.html one. MWE is the R Notebook template: the plot(cars) image does not show.
Per suggestions listed here: RStudio notebook does not show data.frames when I compile, I tried older/newer/dev versions of rmarkdown. I also tried newer/dev versions of knitr. Nothing helped. I have RStudio version 1.0.136.
> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X Yosemite 10.10.5
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 base
other attached packages:
[1] devtools_1.12.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.8 withr_1.0.2 digest_0.6.11 rprojroot_1.2 R6_2.2.0
[6] jsonlite_1.2 backports_1.0.5 git2r_0.15.0 magrittr_1.5 evaluate_0.10
[11] highr_0.6 httr_1.2.1 stringi_1.1.2 curl_2.3 rstudioapi_0.6
[16] rmarkdown_1.3 tools_3.3.2 stringr_1.1.0 yaml_2.1.14 rsconnect_0.7
[21] base64enc_0.1-3 memoise_1.0.0 htmltools_0.3.5 knitr_1.15.8
Thanks to RStudio for pointing out that this is expected behavior. I had switched the chunk output setting to Chunk Output in Console so I could view plots in the plot window. I didn't realize that all chunks must be run inline to appear in the notebook. I switched back to Chunk Output Inline, ran the chunks, and all was well.

Resources