I have installed a package in R (ggmap), but when I try to use it R gives an error:
> library()
... (all the rest)
gdata Various R programming tools for data
manipulation
ggmap A package for spatial visualization with Google
Maps and OpenStreetMap
ggplot2 An implementation of the Grammar of Graphics
...
> library("ggmap")
Error in FUN(structure(c("write_png", "read_png"), .Names = c("write_png", :
no such symbol write_png in package/Library/Frameworks/R.framework/Versions/3.0/Resources/library/png/libs/png.so
Error: package or namespace load failed for 'ggmap'
Any suggestion? Thanks!
PD:
sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
EDIT, solution:
Delete ~/Applications/R.app and Library/Frameworks/R.framework and install R again.
Could in be that you have another R installation for an earlier version 3.0 vs the 3.0.1 showing in your sessionInfo()?
Error in FUN(structure(c("write_png", "read_png"), .Names =
c("write_png", : no such symbol write_png in
package/Library/Frameworks/R.framework/Versions/3.0/Resources/library/png/libs/png.so
Error: package or namespace load failed for 'ggmap'
Go to the RStudio-->Options-->Global-->'General'-->R Version
Change the R Version to the latest one which you want to use.
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]
}
I am using stemDocument for stemming text document using tm package in R. Example code:
data("crude")
crude[[1]]
stemDocument(crude[[1]])
I get an error message:
Error in loadNamespace(name) : there is no package called ‘Snowball’
I have installed SnowballC package and unable to find Snowball package. Below is my sessionInfo():
R version 2.15.3 (2013-03-01)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
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] SnowballC_0.5 tm_0.5-8.3
loaded via a namespace (and not attached):
[1] slam_0.1-31 tools_2.15.3
Does it require any other package or Snowball?
Just try to install the SnowballC packages to R
install.packages("SnowballC")
library(SnowballC)
It should work.
You have an older version of pkg:tm. The current version of tm has a DESCRIPTION file that lists SnowballC as a "Suggests". Older versions suggested Snowball.
Package: tm
Title: Text Mining Package
Version: 0.5-10
Date: 2014-01-07
Authors#R: c(person("Ingo", "Feinerer", role = c("aut", "cre"),
email = "feinerer#logic.at"),
person("Kurt", "Hornik", role = "aut"),
person("Artifex Software, Inc.", role = c("ctb", "cph"),
comment = "pdf_info.ps taken from GPL Ghostscript"))
Depends: R (>= 2.14.0)
Imports: parallel, slam (>= 0.1-31)
Suggests: filehash, proxy, Rcampdf, Rgraphviz, Rpoppler, SnowballC, XML
This is the message you currently get from CRAN:
Package ‘Snowball’ was removed from the CRAN repository.
Formerly available versions can be obtained from the archive.
Archived on 2014-03-16 at the request of the maintainer.
You should update to the current version of tm. Try this:
update.packages("tm", checkBuilt = TRUE)
I try to install R package "methods" over R 3.0.1:
> install.packages("methods")
> Warning message:
package ‘methods’ is not available (for R version 3.0.1)
Is there any way to install 'methods' over R 3.0.1 or should I switch to R 3.0.0?
Thank you
methods is part of base R, you don't have to install it with install.packages, as it is already bundled with your R 3.0.1 installation.
You will see that loading the package will not provide any error :
library(methods)
But you don't even have to do that, as it is already loaded by default in your R session.
methods is a base package, along with the following packages
base
compiler
datasets
graphics
grDevices
grid
methods
parallel
splines
stats
stats4
tcltk
None of these packages are on CRAN, they only exist as part of base R.
See also the R FAQ Section 5.1.1.
I have created a package that depends on Rcpp and RcppArmadillo. My package operates smoothly without a problem on the R console. However, when I try to loaded it from JGR console it reports the following error
Error: package 'Rcpp' 0.9.9 is loaded, but >= 0.9.10 is required by 'RcppArmadillo'
Actually, I have updated Rcpp to version 0.9.10 on my machine. In the R console you can see that
sessionInfo()
attached base packages:
[1] compiler stats graphics grDevices utils datasets methods base
other attached packages:
[1] prophecy_2.1 XLConnect_0.1-9 XLConnectJars_0.1-4 rJava_0.9-3 RcppArmadillo_0.2.36 Rcpp_0.9.10
I appreciate the help.
This has nothing to do with Rcpp and is all about your R patch:
Print the result of .libPaths()
Look at the result of library()
Do that both on the console and with JGR. You probably have different outcomes.
Delete the old Rcpp 0.9.9 in the path added by JGR.