I'm currently running R version 3.4.2 on Windows and have ggplot2 (via tidyverse) and sf package versions 3.4.2. I'm attempting to map spatial data using the ggplot2 sf kit.
When trying to run geom_sf, I receive an error: could not find function "geom_sf".
When I search the ggplot2 package using ls("package:ggplot2"), geom_sf is not listed in the library files.
I installed devtools and ran devtools::install_github("tidyverse/ggplot2"). However, I receive an error: Installation failed: Failed to connect to raw.githubusercontent.come port 443: Timed out. I assume the firewall at work is halting this connection.
To get around this, I tried downloading the zip manually from https://github.com/tidyverse/ggplot2 and running install.packages('ggplot2-master.zip', lib = 'C:/filepath') and receive the error: package 'ggplot2-master.zip' is not available (for R version 3.4.2). I was getting the same error before I updated from 3.4.1.
TLDR: I'm having the same issue as this user: Error when plotting sf object --- Error: could not find function "geom_sf"
but the solution does not work for me.
Does anyone see where I may be missing something? Or how to access this highly referenced (more streamlined) package?
If you downloaded from the URL you cited then the appropriate next step would be to execute this at the R session command line assuming your package is in the working directory:
install.packages('ggplot2', repo=NULL, lib = 'C:/filepath')
The .zip extension is implicit in trying to install from a binary windows file and you need to tell it NOT to attempt downloading from CRAN.
Related
I am trying to create clustered box plots in R. Everything about my code seems on track, but when I try to run it I get the error warning
"Error in loadNamespace(name) : there is no package called ‘digest’.
When I try to download the package digest in the R package Installer I get a bunch of errors stating that the download of digest failed.
How do I get the digest package, OR is there a way to do clustered box plots without this? Thanks!
I had the same problem with install.packages("digest") on OS10.11.6 (running with the defaults). But it worked by specifying the repos:
install.packages('digest', repos='http://cran.us.r-project.org')
I had a similar error message recently and managed to solve the problem by downloading the tar.gz file directly from the CRAN Repository (see https://cran.r-project.org/web/packages/digest/index.html and download "digest_0.6.15.tar.gz") and then you can install it in RStudio (Tools -> Install Packages -> Install from Package/Archive File).
I am very new to this community.
My aim is to use R for statistical analysis but some errors occurred.
In the first step, I want to load the "XLConnect"-package, in order to open an xlsx-data file, with this code:
install.packages('XLConnect')
library(XLConnect)
Answer was "package ‘XLConnect’ successfully unpacked and MD5 sums checked", after which the following error was given:
Error in library(XLConnect) : the package ‘XLConnect’ doesn't exist.
I also tried the xlsx package, but in this case always got:
Error in -library('openxlsx') : invalid argument to unary operator
or, that the package openxlsx, doesn't exist but some line before it told me the download, installation and check sums were correct!
Additionally, when I try to change the directory in a script, using
getwd(), the following error occurs:
Error in -getwd() : invalid argument to unary operator
When I type it in the console it works.
I downloaded R here: https://cran.r-project.org/bin/windows/base, installed R version 3.4.3 as well as R Studio.
I already looked in the community for some hints but neither could solve my problem:
XLConnect function is not passing argument to system.file
Error when installing XLConnect in RStudio
MY OS is Windows 10, I tried the 32-bit as well as the 64-bit version of R and installed fitting Java-Versions for both verisons( that was the first error that occured but now isn't there anymore).
I tried to load the packages from several CRAN-Mirrors but always the same error occurs (e.g. Germany(Göttingen),Germany(Münster), Belgium(Ghent) or Switzerland ).
Maybe I missed some very basic setting. Is the information I provided enough or do you need more?
Thanks a lot in advance for your support!
Thanks a lot! I installed java 32-bit and 64-bit versions the way it is recommended here: https://www.r-statistics.com/2012/08/how-to-load-the-rjava-package-after-the-error-java_home-cannot-be-determined-from-the-registry/ and I installed the rJava package like this: install.packages("rJava")
library(rJava) and here: https://askubuntu.com/questions/176115/what-is-the-best-way-of-installing-the-r-package-xlconnect I found that this here should work to register R correctly: sudo R CMD javareconf but then I get the error that the console got an unexpected symbol. Or Do you know how to register Java Development Kit in R correctly. I installed jdk-8u161-windows-x64.
Make sure you have Java Development Kit installed and correctly registered in R.
Please be patient with me as I'm a total noob, but I'm really trying to learn.
I'm trying to make a choropleth map for my country, and found an R package on Github that handles it excellently. However, I'm working on a university computer and I don't have write privileges on any drive but M://, so whenever the package tries to install on C:// it obviously throws an error. This hasn't been a problem since I can just specify a libpath as an argument on install.packages, but devtools::install_github does not seem to have such an argument.
I tried using
with_libpaths(new = "M:\R\win-library\3.2", install_github('diegovalle/mxmaps'))
But I got an error message saying
with_libpaths' is deprecated. Use 'withr::with_libpaths' instead.
I take this to mean that I need to install the "withr" package in order to use that? However, I keep getting errors when trying to install that package. First, I got
Warning in install.packages : installation of package ‘withr’ had
non-zero exit status
because of the not having access to C:// issue. I usually bypass this by installing directly from the binaries, but when I try that it tells me
"Warning in install.packages : package ‘withr’ is not available (for R
version 3.2.2)".
Other than updating my version of R (which will be a nighmare since I don't have installation privileges on this machine), how else can I either install withr or find another way to specify the directory to install the package from github?
I would suggest you to go with latest version of 3.4.All above mentioned packages are available under latest version.
Two ways to set local library paths (at least on Linux running R 3.5.3):
(1) At the beginning of your script, set the the .libPaths option to your local library path, i.e.: .libPaths("M:\R\win-library\3.2")
(2) Add to your .Renviron file a line that specifies your local library path: i.e.: R_LIBS="M:\R\win-library\3.2"
Note: For (1) You will need to manually run every time you start a new R session, whereas (2) will be set automatically when R starts.
My end goal is to be able to use the geoR and sp packages in R on an AWS EC2 Linux instance. The first hurdle is getting an older version of R since 3.3 doesn't support TCL/TK (at least that I've found).
After unpacking R-3.2.5.tar.gz and following the instructions in the INSTALL file (along with these configure options), a search in the config.log shows the following for TCL and TK:
configure:32908: checking for tclConfig.sh
configure:32950: checking for tclConfig.sh in library (sub)directories
configure:33143: checking for tcl.h
conftest.c:228:17: fatal error: tcl.h: No such file or directory
#include <tcl.h>
config.status:1893: creating src/library/tcltk/DESCRIPTION
config.status:1893: creating src/library/tcltk/Makefile
config.status:1893: creating src/library/tcltk/src/Makefile
ac_cv_env_TCLTK_CPPFLAGS_set=
ac_cv_env_TCLTK_CPPFLAGS_value=
ac_cv_env_TCLTK_LIBS_set=
ac_cv_env_TCLTK_LIBS_value=
r_cv_header_tcl_h=no
TCLTK_CPPFLAGS=''
TCLTK_LIBS=''
TCL_CONFIG=''
use_tcltk='no'
R installs successfully, but running capabilities("tcltk") confirms that something went wrong, as it returns FALSE.
Following the hints here, I searched for tclConfig.sh and tkConfig.sh, and realized I hadn't installed the appropriate dependencies, namely tcl-devel, and tk-devel.
Running yum list available shows a package for tcl-devel.x86_64 but nothing for tk. I downloaded source files for TCL and TK from here, but couldn't find source files for any devel packages.
So now I'm at a loss on how to proceed. Has anyone been through this process that can shed some light on it?
UPDATE
After reading the comment below, I'm afraid I didn't do my due diligence in researching TCL/TK and R 3.3.
My very early efforts to troubleshoot the whole problem consisted of the following workflow- First, without even considering an older version of R, I ran install.packages("geoR") in 3.3.2. This resulted in installation of package 'geoR' had non-zero exit status, along with:
Error: package 'tcltk' does not have a namespace
ERROR: lazy loading failed for package 'geoR'
So, naturally, I ran install.packages("tcltk") which resulted in package 'tcltk' is not available (for R version 3.3.2)
As I mentioned before, this was very early on. I took the message literally and didn't think to look further into TCL/TK for 3.3, but instead started looking to get an earlier version of R, since I had been successfully running geoR and sp on another system that had R 3.2.5.
I am facing a problem with an R package that I am writing and trying to build with a pre-compiled shared library. Let me try to briefly describe the problem:
this package (let's call it mypack) relies on a shared library mylib.dll that is already compiled and that I cannot compile on the fly while building the R package.
the library mylib.dll has been compiled on a x64 machine under Windows and can be loaded in R with dyn.load.
the package contains the required file NAMESPACE, where useDynLib(mylib.dll) is specified. The function .onLoad containing the instruction library.dynam('mylib.dll', pkg, lib) is also specified in a file zzz.R.
the R package mypack is built with Rtools using the usual command Rcmd INSTALL, and I then add a directory libs where I save mylib.dll.
when I try to load the package in R with library(mypack), I get the following error message:
Error: package 'mypack' is not installed for 'arch=x64'
This is puzzling me. Why can the shared library be loaded smoothly in R, but when I build a package using it I am getting this weird error message?
Thank you very much in advance for your help!
That error message comes from this code in library:
if (nzchar(r_arch) && file.exists(file.path(pkgpath,
"libs")) && !file.exists(file.path(pkgpath, "libs",
r_arch)))
stop(gettextf("package %s is not installed for 'arch=%s'",
sQuote(pkgname), r_arch), call. = FALSE, domain = NA)
which is telling me you need a {package}/libs/{arch} folder in your built package (ie the installed directory) with an {arch} that matches your system's arch, as given by r_arch <- .Platform$r_arch
I'm guessing your build has failed to make this correctly. Is there any C code in your source?