Install SPDEP, SPLM and other packages on Amazon EC2 Linux Instance - r

I set up Rstudio on AmazonEC2. I am connected to the instance via PuTTY. To install packages like spdep, readtxt, splm, and dplyr.
I have tried
sudo -s
sudo yum install spdep
However, I have this Error
Loaded plugins: priorities, update-motd, upgrade-helper
No package spdep available.
In mean time, when I code install.packages("spdep") on R console at the EC2 instance, I have error
ERROR: dependencies ‘classInt’, ‘units’ are not available for package ‘sf’
* removing ‘/home/henok/R/x86_64-redhat-linux-gnu-library/3.4/sf’
Warning in install.packages :
installation of package ‘sf’ had non-zero exit status
ERROR: dependencies ‘sf’, ‘deldir’, ‘expm’ are not available for package ‘spdep’
* removing ‘/home/henok/R/x86_64-redhat-linux-gnu-library/3.4/spdep’
Warning in install.packages :
installation of package ‘spdep’ had non-zero exit status
The downloaded source packages are
in‘/tmp/RtmpMBCgvy/downloaded_packages’

I switched to create a ''window instance' rather than Linux and a for a connection I have used a 'remote desktop connector' which is found by default in any windows 10. To successfully connect, please don't forget to make 'OFF firewall'', and to edit 'Inbound IP" to receive all incoming IP address (found in the instance setting). Once I have connected to the instance via RDC, then a simple run as if we sit in front windows 10. Then, I am able to install, R, R studio and run it. Then install.packages() as we do to rstudio desktop will be the next step. Now, I am able to run my stuff successfully with a 64GB RAM in the cloud.

Related

R can't access to the internet on user level but on sudo level

As described, I tried install.packages(), getURL() as well as other several internet related fucntions, all failed to access to internet (no matter in commandline or RStudio). However, if I do system("ping 1.1.1.1"), it does transmit packages. On the other side, using sudo su and then R can access to the internet without any problem. So I only can install packages on sudo level.
Also tried switching to phone hotspot network, failed as well.
No proxy enabled.
R version: 4.2.0
System: Ubuntu 20.04 LTS 64-bit
Edit: connection error shows below:
> install.packages("abc")
Warning in install.packages :
unable to access index for repository https://cloud.r-project.org/src/contrib:
cannot open URL 'https://cloud.r-project.org/src/contrib/PACKAGES'
Installing package into ‘/home/kuai/R/x86_64-pc-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)
Warning in install.packages :
unable to access index for repository https://cloud.r-project.org/src/contrib:
cannot open URL 'https://cloud.r-project.org/src/contrib/PACKAGES'
Warning in install.packages :
package ‘abc’ is not available for this version of R
A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
Wrong proxy settings in export

Need help installing rJava on Mac

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}

Errors when installing specific R packages

I am receiving error messages when I try to install specific packages in R. The packages in question are pillar and osrm. I recently updated several packages without any problems so I'm not sure why these ones are causing an issue.
The error message I recieve when installing either of the two packages is as follows:
There is a binary version available but the source version is later:
binary source needs_compilation
osrm 3.2.0 3.3.1 FALSE
installing the source package ‘osrm’
trying URL 'https://cran.rstudio.com/src/contrib/osrm_3.3.1.tar.gz'
Content type 'application/x-gzip' length 119746 bytes (116 KB)
downloaded 116 KB
'\\CompanyX\ProgData\R_Studio\R-34~1.1' is not recognized as an internal or external command,
operable program or batch file.
Warning in install.packages :
running command '"X:/R_Studio/R-34~1.1/bin/i386/R" CMD INSTALL -l "X:\R_Studio\R-3.4.1\library" C:\Users\abc123\AppData\Local\Temp\RtmpKk0RxD/downloaded_packages/osrm_3.3.1.tar.gz' had status 1
Warning in install.packages :
installation of package ‘osrm’ had non-zero exit status
I have seen in other posts that the binary/source issue is caused by recent updates to the package and this requires a compiler. As I am on a company machine, I am unable to easily install RTools. I have also installing tried older versions of each package - this results in the same error.
I have tried to download from Github directly via devtools::install_github("rCarto/osrm") but I always get the following error:
Installation failed: Failed to connect to raw.githubusercontent.com port 443: Timed out
I'm not sure if this is due to a company firewall blocking the access, but it seems to occur with any package I try to download from GitHub.
Finally, I have tried to install directly from the tar.gz file or a zip file downloaded from CRAN/GitHub. The former results in the following error:
'\\CompanyX\ProgData\R_Studio\R-34~1.1' is not recognized as an internal or external command,
operable program or batch file.
Warning in install.packages :
running command '"X:/R_Studio/R-34~1.1/bin/i386/R" CMD INSTALL -l "X:\R_Studio\R-3.4.1\library" "C:/Users/abc123/AppData/Local/Temp/RtmpKk0RxD/downloaded_packages/osrm_3.3.1.tar.gz"' had status 1
Warning in install.packages :
installation of package ‘C:/Users/abc123/AppData/Local/Temp/RtmpKk0RxD/downloaded_packages/osrm_3.3.1.tar.gz’ had non-zero exit status
While the zip file route does place the package folder in the R root library folder but then results in a system error requesting the latest version of R and then crashes RStudio completely.
Any advice as to either successfully install these packages or a specific issue I could raise with the company IT department would be much appreciated.

Error starting OpenCPU in rstudio OnAttach failed

I am trying to get a simple OpenCPU Apps (from https://www.opencpu.org/download.html).
Since I am on Ubuntu on AWS, I follow the instructions for Ubuntu:
# Requires Ubuntu 14.04 (Trusty) or 16.04 (Xenial)
sudo add-apt-repository -y ppa:opencpu/opencpu-1.6
sudo apt-get update
sudo apt-get upgrade
# Installs OpenCPU server
sudo apt-get install -y opencpu
# Done! Open http://yourhost/ocpu in your browser
# Optional: installs rstudio in http://yourhost/rstudio
sudo apt-get install -y rstudio-server
Goes through all right.
Next I try to install the package in Rstudio:
install.packages("opencpu")
Installing package into ‘/home/ruser/R/x86_64-pc-linux-gnu-library/3.3’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/opencpu_1.6.1.tar.gz'
Content type 'unknown' length 563159 bytes (549 KB)
==================================================
downloaded 549 KB
* installing *source* package ‘opencpu’ ...
** package ‘opencpu’ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (opencpu)
The downloaded source packages are in
‘/tmp/RtmpON3Ujv/downloaded_packages’
> library(opencpu)
Initiating OpenCPU server...
Using config: /home/ruser/.opencpu.conf
OpenCPU started.
[httpuv] http://myserver/rstudio/p/1529/ocpu
Error : .onAttach failed in attachNamespace() for 'opencpu', details:
call: rhttpd$init()
error: could not find function "startDynamicHelp"
Error: package or namespace load failed for ‘opencpu’
This is where I get the error. Tried googling the error but no luck.
#gaurav is correct. The instructions on opencpu are very misleading, because it looks like they're showing a single set of instructions, but in fact, the R commands are for running opencpu in an interactive R session, not with your newly installed opencpu cloud server.
To run the sample apps on your new cloud server (which is what I assume you are trying to do), you need to follow the instructions for the cloud server.
Here's the link to the cloud server docs that helped me:
https://cran.r-project.org/web/packages/opencpu/vignettes/opencpu-server.pdf
Specifically, to run the sample apps, you'll need to start an R session as root, and install the packages:
sudo -i
R
#then from r session
library(devtools)
install_github("opencpu/gitstats")
install_github("opencpu/stocks")
#then quit
quit()
exit
then restart the opencpu service:
sudo service opencpu restart
then, you can navigate to the package using the opencpu api. In a web browser, go to:
http://localhost/ocpu/library/gitstats/www/
and voila-

LOCAL R Package not running because of missing doMC dependancy

I am trying to get a local package to work but it depends on doMC which is only available for Mac and I don't have a Mac. Is there any way I can still make the package work? I use the following code:
install.packages("~/R/AMT/Code/CLVTools_1.0.5.tar.gz",repos=NULL,type="source")
After running the code I get the following error message:
Installing package into ‘C:/Users/alexa_000/Documents/R/win-library/3.0’
(as ‘lib’ is unspecified)ERROR: dependency 'doMC' is not available for package 'CLVTools'
* removing 'C:/Users/alexa_000/Documents/R/win-library/3.0/CLVTools'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-30~1.2/bin/x64/R" CMD INSTALL -l "C:\Users\alexa_000\Documents\R\win-library\3.0" "C:/Users/alexa_000/Documents/R/AMT/Code/CLVTools_1.0.5.tar.gz"' had status 1
Warning in install.packages :
installation of package ‘C:/Users/alexa_000/Documents/R/AMT/Code/CLVTools_1.0.5.tar.gz’ had non-zero exit status
Does anyone have any ideas how to run the package anyways?
Any kind of help highly appreciated
Based on the documentation, that package should run on any Unix system, not just OS X.
Your best bet is to install a virtual machine and put a Linux distro on it, or dual-boot your Windows PC with Linux.
More generally, if you are going to be doing a lot of data processing with open source tools like R, Linux is your friend.

Resources