I am trying to generate notes for the reports package https://github.com/trinker/reports/ , and followed the steps from the youtube video http://goo.gl/x9ulf0 . I did run the chunk Tyler has there http://goo.gl/XHouuc but when I try to generate the notes i keep getting the following error message:
> notes()
Error in value[[3L]](cond) :
Possible causes:
1) The main file directory is not set as the working directory
2) ~/ARTICLES/notes.xlsx or ~/ARTICLES/notes.csv does not exist
I then tried to set my working directory to different places and even to move the ARTICLES directory to my home ~ directory, but i keep getting the exact same message no matter where i place the wd. i read the source code for the notes function but couldn't figure out where the problem might be. the notes2 function also gives me the same error
here is my sessioninfo:
> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
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] knitcitations_0.4-7 bibtex_0.3-6 knitr_1.4.1 slidifyLibraries_0.3
[5] slidify_0.3.52 reports_0.2.0
loaded via a namespace (and not attached):
[1] digest_0.6.3 evaluate_0.4.7 formatR_0.9 httr_0.2 markdown_0.6.3
[6] RCurl_1.95-4.1 rJava_0.9-4 stringr_0.6.2 tools_3.0.1 whisker_0.3-2
[11] xlsx_0.5.1 xlsxjars_0.5.0 XML_3.95-0.2 xtable_1.7-1 yaml_2.1.8
any thoughts on what the problem might be?
#Ricardo Pietrobon Thank you for bringing this to my attention.
Ok the problem is that the xlsx package relies on Depends and not Imports to load the call to .jnew from the rJava package. This means if you have used library(xlsx) then read.xlsx works fine, however if only the read.xlsx is attached via namespace then rJava's .jnew is not called. hence the error. This is confirmed in that the NAMESPAE file for xlsx contains:
import("xlsxjars")
exportPattern("^[^\\.]")
This became a problem because CRAN recently required more restrictive checks and I started using importFrom rather than import and relying on Depends. I actually recieved a warning along these lines from Prof. Brian Ripley about relying on Depends. At the time I didn't understand it but heeded it. I now get exactly what he was talking about.
For the time being I have added rJava to the Depends field in the DESCRIPTION file. This throws a NOTE in the CRAN check as I'm Depending but not importing and needs to be removed after xlsx is updated.
I opened an issue with the xlsx package in the link below regarding the problem. Hopefully this gets fixed and uploaded soon. In the mean time notes() should be operating fine.
https://code.google.com/p/rexcel/issues/detail?id=24&thanks=24&ts=1379267751
I opened an issue at report's GitHub concerning this and as I believe the original problem has been solved, further conversation can be directed there.
Related
I am getting a circular dependency error for my R package when running CHECK:
checking package dependencies ... ERROR
There is circular dependency in the installation order:
One or more packages in
then a long list of packages.
However, my Depends category in DESCRIPTION is very minimal:
Depends: methods, R (>= 3.5.0), magrittr
And all other referenced packages are in either Imports or Suggests. One package I have in Imports also lists my package in their Imports, but I did not think that would lead to a dependency issue. I don't think any of the other packages I have in DESCRIPTION list mine in theirs.
I've searched quite a bit online but found no relevant solutions. Any ideas? Thanks in advance for the advice.
Session info:
R version 4.0.5 (2021-03-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/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.0.5 tools_4.0.5 tinytex_0.31 xfun_0.28
Depends and imports both require a dependency. The main difference is that imports doesn't add items to the user's search path. See here or here. You can't list a package under your "imports" that lists you under their "imports" -- that part is the same as "depends." Packages use functions from packages all the time, but the sharing is just one-way.
One possible work-around is copying the function (with permission from the other package author) into your own package.
Another option that I've seen used by other packages is to move shared logic to a separate helper package and then both packages can Import that helper package.
Finally, if it's a function you don't really need you can move it to suggests and then check if that package is installed only when you need the function and can throw an error if not.
I have an issue with the library path of R. Maybe the answer is out there already, but I was not able to find it. I am using R together with RStudio Version 1.1.456. All my additional libraries used to be in a directory dir1 <- \\SHARE\TOOLS_OLD$\R-3.5.1 which I append with .libPaths(dir1). In this setup, everything works as expected.
The problem occured after I copied all the libraries in directory \\SHARE\TOOLS_OLD$\R-3.5.1 to a new location \\NAS\TOOLSNEW$\R-3.5.1. I did not update the R version and I want to keep all the package versions the same such that I have exactly the same setup as before. That is why I did not reinstall the packages in the new location.
When I open a new R session and run the three lines of code
dir2 <- \\NAS\TOOLSNEW$\R-3.5.1
.libPaths(dir2)
.libPaths()
I get the correct output of .libPaths()
[1] "\\\\NAS/TOOLSNEW$/R-3.5.1" "C:/Apps/R-3.5.1/library"
but R also throws an error:
Error: invalid version specification ‘NA’
In addition: Warning message:
In utils:::packageDescription(packageName, fields = "Version") :
no package 'knitr' was found
Apparently some packages remember the original location where they were installed. Is there a way to copy packages to a new location without reinstalling them? If that is not possible, is there an easy (i.e. non-manual) way to reinstall my package tree without upgrading any of the packages (including the dependencies) i.e. defining the version of each package?
Thanks for your help!
PS: Here is my session info, just in case.
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=German_Switzerland.1252 LC_CTYPE=German_Switzerland.1252
LC_MONETARY=German_Switzerland.1252 LC_NUMERIC=C
[5] LC_TIME=German_Switzerland.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.5.1 tools_3.5.1 yaml_2.2.0
The problem can have many causes, e.g. there might be some dependencies which are lost by copying the package folder or that the registry entries don't match anymore, but I'm guessing here. When you copy packages from older versions you have to run update.packages (but this might update any package to the currently available version, which you don't want). Check out the R-FAQ and this Stackoverflow question.
You can install packages of a certain version with the devtools package.
install.packages("devtools")
require(devtools)
install_version(somePackage, version = neededVersion)
How I did it was I created a data.frame of all the required packages with the corresponding version number, like
> requiredPkgs
Package Version
condformat "condformat" "0.9.0"
DT "DT" "0.17"
formattable "formattable" "0.2.1"
ggplot2 "ggplot2" "3.3.3"
ggthemes "ggthemes" "4.2.4"
htmlTable "htmlTable" "2.1.0"
and then installed them in a loop
for(iPkg in requiredPkgs) {
install_version(iPkg[1], version = iPkg[2]
}
After opening R Studio the following Error-message appears:
This error also always appears in the end when I am trying to install or load packages:
Error: invalid version specification ‘NA’
In addition: Warning message:
In utils:::packageDescription(packageName, fields = "Version") :
no package 'knitr' was found
Some maybe helpful facts:
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: i386-w64-mingw32/i386 (32-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 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.5.1 tools_3.5.1
I am working on a company laptop without admin-rights, why I have set my library path manually to the following writable folders:
> .libPaths()
[1] "\\\\HOME.COMPANYNAME/USERNAME$/Files/R/win-library/3.5"
[2] "\\\\HOME.COMPANYNAME/USERNAME$/Files/R/R-3.5.1/library"
The second .libPath() was created automatically some weeks after the first.
I cannot manually delete both .libPaths from my laptop due to missing admin-rights.
I also tried to remove the libraries as recommended in several posts
with:
R_LIBS=C:/Program Files/R/R-2.15.2/library
Nevertheless, the .libPaths stayed the same after this:
> .libPaths()
[1] "\\\\HOME.COMPANYNAME/USERNAME$/Files/R/win-library/3.5"
[2] "\\\\HOME.COMPANYNAME/USERNAME$/Files/R/R-3.5.1/library"
I also tried setting a new .libPath on a local folder C:// :
.libPaths("C:\\Users\\USERID\\Desktop\\R")
After that, the first .libPath is replaced by the new local one, while the second .libPath stays the same and I am getting the same error again:
> .libPaths()
[1] "C:/Users/USERID/Desktop/R"
"\\\\HOME.COMPANYNAME/USERNAME$/Files/R/R-3.5.1/library"
Error: invalid version specification ‘NA’
In addition: Warning message:
In utils:::packageDescription(packageName, fields = "Version") :
no package 'knitr' was found
Setting the new .libPath on the local folder C:/ allows me to install and load packages but only temporarly within the R Studio-session:
> install.packages("FDboost")
Installing package into ‘C:/Users/USERID/Desktop/R/R-3.5.1/library’
(as ‘lib’ is unspecified)
After quitting and restarting the R session, the newly defined .libPath on C:/ as well as the installed packages are deleted.
Maybe I have to add the .libPath to the filepath as recommended by #r2evans so that it is saved also after quitting the R session? I did not figure out how to do so...
For the last months, I was able to install and load packages from these two library paths, maybe there was an antivirus update that now makes problems? I did not change any settings but it seems like R cannot find or edit the installed packages anymore.
Deinstalling R or RStudio is not a possible solution, since I need admin rights to reinstall them.
Since other posts did not bring the solution so far, maybe anybody has more ideas?
For my company, we have a repository for internally created packages at an internally hosted location. It is accessible while we are on our network, but inaccessible while we're off it.
We have an internal package that forces standards and configuration and contains a function that builds an internal profile at the project, user, or system level (So we can quickly configure their system to select packages from CRAN and the local along with a number of other settings)
the .Rprofile that's generated contains (among other things) the following:
repos <- getOption('repos')
repos["cloud"] <- "https://cloud.r-project.org"
repos['internal'] <- 'http://path/to/repo/'
options(repos = repos)
This works great when we're in the network, but outside of the network, install.packages still checks that internal repo (regardless of the order of the repos).
This leads to very long waits for timeouts.
I'm trying to find a way to either:
Include the repo conditionally
Reduce the timeout of install.packages
options(timeout = 10) appears to have no effect.
If it will quickly determine that the repo is unavailable, I think there won't be too much of a drop in user experience, but as it stands right now, it will take 2-3 mins to finally reject that repo.
EDIT: All other things being equal, setting the above options should reproduce the timeout issue, unless http://path/to/repo exists.
But in case this is a platform issue with options(timeout = X), this is my session info:
> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-apple-darwin16.4.0 (64-bit)
Running under: macOS Sierra 10.12.3
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
loaded via a namespace (and not attached):
[1] tools_3.3.3
The semester has ended and I'm now bringing some packages up to R 2.15 (I did not want to change them while students were using them). So I'm doing my usual thing, which worked under R 2.14. As far as I can see, the documentation has not changed with respect to any of this, but I may have missed it.
I have edited my package ChemoSpec but when I go to check it, R gives an error about packages required but not available, then lists them. These packages are available, they are in a local directory which is pointed a-:
.libPaths()
[1] "/Users/bryanhanson/R_pkgs"
[2] "/Library/Frameworks/R.framework/Versions/2.15/Resources/library"
The allegedly missing packages are in fact in /Users/bryanhanson/R_pkgs.
I am aware my .Rprofile is skipped by the checking process, so the .libPaths are not being set by .Rprofile Instead, I have a check.Renviron file which is located in /Users/bryanhanson/.R and contains the following lines:
# Bryan's check.Renviron for customizing check environment
# resides in /Users/bryanhanson/.R
R_LIBS = /Users/bryanhanson/R_pkgs
I have tried to check with the following commands in the terminal
R --as-cran CMD check ChemoSpec
R --vanilla CMD check ChemoSpec
The response to each of these is slightly different, but both fail because of not finding the dependencies, because, apparently, R is not looking in /Users/bryanhanson/R_pkgs even though I think I have told it do so.
Any suggestions? It must be something simple.
Here is the sessionInfo():
sessionInfo()
R version 2.15.0 (2012-03-30)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
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] sos_1.3-1 brew_1.0-6