I am trying to install an R package along with its dependencies. But it is throwing error.
$ install.packages(rvest_0.3.5.tar.gz, dependencies=True)
-bash: syntax error near unexpected token `rvest_0.3.5.tar.gz,'
I am new to R please help me how can I download this along with it dependencies.
Before this, I tried following
$ R CMD INSTALL rvest_0.3.5.tar.gz
* installing to library ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library’
ERROR: dependencies ‘httr’, ‘magrittr’, ‘selectr’ are not available for package ‘rvest’
But it failed with dependent packages are missing error. And obviously it is cumbersome to install the dependent packages manually. Hence I tried package.install
You need to run it with quotes and capital TRUE:
install.packages("rvest_0.3.5.tar.gz", dependencies = TRUE)
Note this will only work if you have unix-like system and the file is located in your current working directory (check with running getwd() from your R session). Otherwise you need to provide full path to the file (like "~/somefolder/mydata/rvest_0.3.5.tar.gz").
If you run Windows, then you need .zip file instead of .tar.gz.
If you are connected to internet, just run:
install.packages("rvest")
Related
I am trying to download the package Xlconnect on my mac but I keep getting errors. I was able to figure out that it was because mac has some issue with Java and that I need to first resolve that before. But I've had no luck so far.
One of the things I tried was this: https://www.chrisjmendez.com/2018/11/16/installing-xlconnect-and-rjava-on-macos/
But it didn't work as well.
Can someone who has been able to successfully install rJava help me out please?
configure: error: One or more Java configuration variables are not set.
Make sure R is configured with full Java support (including JDK). Run
R CMD javareconf
as root to add Java support to R.
If you don't have root privileges, run
R CMD javareconf -e
to set all Java-related variables and then install rJava.
ERROR: configuration failed for package ‘rJava’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava’
Warning in install.packages :
installation of package ‘rJava’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/47/523c7yns0dvgc2cy147fbxrh0000gn/T/RtmpkLRoEh/downloaded_packages’
It seems as you have not set up your environment with java variables.
Try adding this to either your ~/.zshrc or ~/.basrc
export PATH={PATH_TO_JAVA_INSTALLATION}:$PATH
export JAVA_HOME={SAME_PATH_TO_JAVA_INSTALLATION}
Your Java Path is most likely in /Library/Java/JavaVirtualMachines/{some .jdk file}
I tried to install a package in R on the server. it recompiled from sources to install package but I see the following error:
'\pn-s\proj1\p_k\fsh'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.
Error: ERROR: no packages specified
the above path is my workspace that my package is in it.
Do you know how I can fix this problem?
How do i choose the library which the package is install in in Rstudio?
When i run "install and restart" i get this error:
installing to library 'C:/Program Files/R/R-4.0.0/library'
Error: ERROR: no permission to install to directory 'C:/Program Files/R/R-4.0.0/library'
Exited with status 1.
I want it to install on "h:/r_packages"
As I understand you want to install your personal package. I don't find any option for the library path in RStudio. You can run this code in the console:
withr::with_libpaths("h:/r_packages", devtools::install())
You have to run this command when the current directory is the one of the package. Otherwise use the pkg argument of devtools::install to specify the package directory.
The second argument of install.packages is lib, which specifies the library directory.
The help reads:
lib
character vector giving the library directories
where to install the packages.
Recycled as needed.
If missing, defaults to the first element of .libPaths().
So, the below would work, though I cannot try on my end.
install.packages("package_name", lib="h:/r_packages")
I have R 3.2.2 setup installed in my system,with RStudio version 0.99.489. When I tried to install rJava package,
install.packages("rJava")
I am getting following Error:
Warning in install.packages :
downloaded length 4878 != reported length 200
Error in install.packages : subscript out of bounds
But if I run the below command before installing any package,it works fine, but I don't want to do this every time I install a package.
options(repos=structure(c(CRAN="http://cran.us.r-project.org")))
You can stick the line you want executed at every startup in your .Rprofile file which should be in your home directory. I have 3.2.3 version of R and that worked; however I do get a warning message about using a non-http version of the site.
Similarly to you, I was finding the original repository the system was using was failing to install the packages--not finding the package or downloading a file with too few bytes, perhaps because of a transient problem. You might want to consider not putting this in your .Rprofile file or commenting the line outin case this is a temporary workaround.
I want to install http://cran.r-project.org/src/contrib/Archive/mecdf/ using RStudio but when I use
> install.packages('C:\\Users\\jandre\\Desktop\\mecdf_0.6.1.tar.gz', repos=NULL, type="source")
I get this error:
Installing package into ‘C:/Users/jandre/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
Warning in install.packages :
running command '"C:/Program Files/R/R-3.1.1/bin/x64/R" CMD INSTALL -l "C:\Users\jandre\Documents\R\win-library\3.1" "C:/Users/jandre/Desktop/mecdf_0.6.1.tar.gz"' had status 1
Warning in install.packages :
installation of package ‘C:/Users/jandre/Desktop/mecdf_0.6.1.tar.gz’ had non-zero exit status
This occurs in every package I want to install using the tar.gz file. I'm on Win7 x64. RStudio Version 0.98.1028
Can't think of a way to fix this at the moment -- sorry -- but the R administration manual says explicitly:
Note that installing R into a directory whose path contains spaces is not supported, and at least some aspects (such as installing source packages) will not work.
I don't know why this doesn't bite people much more often, given that C:/Program Files/... seems like a relatively normal place to install things on Windows.
I would also expect that the double quotation marks around your R executable name ("C:/Program Files/R/R-3.1.1/bin/x64/R") in the system call should have protected you from this problem ... ?
I had the same error message with the installation of some packages(under Windows 10 OS with R and Rstudio).
It seems that the R software (not R Studio) is dealing with the library where package are installed.
I uninstalled R and Rstudio and installed it a path without space (ex: C:\Program\R).I tried to load the packages that previously failed and it seemed to fix the problem.