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.
Related
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.
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$
When trying to Preview a simple notebook in RStudio, I am getting the following error in the top of the source pane and no nb.html file is created:
"Error creating notebook: no lines available in input"
Screenshot:
> sessionInfo(package = NULL)
R version 3.3.3 (2017-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=German_Austria.1252 LC_CTYPE=German_Austria.1252 LC_MONETARY=German_Austria.1252 LC_NUMERIC=C LC_TIME=German_Austria.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] backports_1.0.5 magrittr_1.5 rprojroot_1.2 htmltools_0.3.6 tools_3.3.3 base64enc_0.1-3 yaml_2.1.14 Rcpp_0.12.12 stringi_1.1.3 rmarkdown_1.8 knitr_1.17
[12] stringr_1.2.0 digest_0.6.12 evaluate_0.10
> RStudio.Version()
$mode
[1] "desktop"
$version
[1] ‘1.0.153’
I wasn't able to replicate the exact error but you could try writing the output html notebook in same line.
---
title: "R Notebook"
output: html_notebook: default
html_document: default
---
I fixed this by opening a new Notebook, copying the contents of my original, error-ing Notebook there, and then overwriting the original Notebook. The error presented, for me, after I moved a folder containing all the files associated with this project to a new location.
I am trying to make a shinyapp which let users upload a certain format of file. After uploading the file, the shinyapp will automatically plot some table and charts using dplyr and rCharts.
It works well when I run it locally using “Run App”. However, when I publish to shinyapp.io, I got this error:
path1="": No such file or directory
After searching on the internet, I haven’t found any solution to solve this problem. Could anyone help me on what the possible reason causing this issue?
Here is my code and my sessionInfo().(It's a little bit long and messy)
https://github.com/johnnychiuchiu/Cheetah_ShinyApp/blob/master/server.r
R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.4 (Yosemite)
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] stringr_1.0.0 dplyr_0.4.2 rCharts_0.4.5 shiny_0.12.2
loaded via a namespace (and not attached):
[1] Rcpp_0.12.1 lattice_0.20-33 assertthat_0.1
[4] digest_0.6.8 mime_0.3 grid_3.2.2
[7] plyr_1.8.3 R6_2.1.0 DBI_0.3.1
[10] xtable_1.7-4 jsonlite_0.9.16 magrittr_1.5
[13] stringi_0.5-5 lazyeval_0.1.10 rstudioapi_0.3.1
[16] whisker_0.3-2 RJSONIO_1.3-0 tools_3.2.2
[19] parallel_3.2.2 httpuv_1.3.3 yaml_2.1.13
[22] rsconnect_0.4.1.4 htmltools_0.2.6
The "h" in "Highcharts" needs to be lowercase, e.g.:
showOutput("h5", "highcharts"),
If that doesn't work: For the deployment, showOutput needs you to detail the path to your rcharts-lilbrary (at least in my case, for whatever reason ^^).
I had a problem which was very similar to yours. Here's my solution:
"ERROR: path[1]="": No such file or directory" when publishing Parallel Coordinates Chart with Shiny
The problem
I am trying to use rmarkdown::render function to generate a standalone html report with tables formated using DT::datatable function. I seem to loose JavaScript dependencies using this approach if I output the report to other directory than the working one.
On the other hand, everything works fine if I press the Knit button in RStudio. Report is generated, tables are formated as expected. I can send the report via email. I can copy the report using ctrl + c and paste it wherever using ctrl + v. It just works. However, it does not work for me if I copy the .html report to other folder using file.copy.
What I tried
I looked at and read Howto include js dependencies of DT datatable in Rmarkdown using knitr and pandoc, I also tried to understand knit DT::datatable without pandoc. I stil cannot get it to work.
As always, there must be some simple option I am missing. Could you help please.
Session Info
R version 3.2.0 (2015-04-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=Slovenian_Slovenia.1250 LC_CTYPE=Slovenian_Slovenia.1250 LC_MONETARY=Slovenian_Slovenia.1250
[4] LC_NUMERIC=C LC_TIME=Slovenian_Slovenia.1250
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] printr_0.0.4 DT_0.1 markdown_0.7.7 rmarkdown_0.8 knitr_1.11 dplyr_0.4.3 stringr_1.0.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.0 digest_0.6.8 assertthat_0.1 R6_2.1.1 jsonlite_0.9.16 DBI_0.3.1 formatR_1.2 magrittr_1.5
[9] evaluate_0.7.2 highr_0.5 stringi_0.5-5 lazyeval_0.1.10 rstudioapi_0.3.1 tools_3.2.0 htmlwidgets_0.5 yaml_2.1.13
[17] parallel_3.2.0 htmltools_0.2.6