R Package Doesn't Install in Jupyter Notebook, But Installs in RStudio and R app - r

I'm trying to install the package PerformanceAnalytics using the following code in a Jupyter Notebook, which I've used to install many packages successfully, such as ggplot2, with the following code:
install.packages("PerformanceAnalytics", repos='http://cran.r-project.org')
But I read on many other questions that adding dependencies=TRUE would solve the issue. Unfortunately, it did not. I keep getting the following error message.
install.packages("PerformanceAnalytics", repos='http://cran.r-project.org',
dependencies=TRUE)
Warning message in install.packages("PerformanceAnalytics", repos =
"http://cran.r-project.org"): “installation of package ‘PerformanceAnalytics’
had non-zero exit status”Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
The package installs without a problem in the R app and RStudio. Is there something I'm missing that Jupyter requires for this specific package? I'm using macOS 10.12.5. Below is the info when I run sessionInfo().
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin11.4.2 (64-bit)
Running under: macOS Sierra 10.12.5
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] R6_2.2.0 magrittr_1.5 IRdisplay_0.4.4 pbdZMQ_0.2-4
[5] tools_3.3.2 crayon_1.3.2 uuid_0.1-2 stringi_1.1.2
[9] IRkernel_0.7.1 jsonlite_1.1 stringr_1.1.0 digest_0.6.10
[13] repr_0.10 evaluate_0.10

The solution from the question at Is it possible to install bioconductor package 'rain' in R Jupyter notebook? solved my issue as well. I was using Anaconda's version of R. I uninstalled Anaconda and instead installed Jupyter Notebook and IRkernal manually which resolved my issue. See the answer from the above link for full details.

Related

R error when installing packages (summarytools)

edit: all screenshots are displayed
I'm teaching stats in Rstudio and we're using the summarytools package. A few of my students are getting different error messages, with the same overall result that the package is not properly installed.
Alex's error seems to download, but not sure if it is installing and the library function cannot find the summarytools package.
Aroun's error is happening mid-install, something about failing to install or load a supporting package 'stringr'.
Zoey's error says something about a non-zero exit status.
While I can run stats in R, I'm a complete newb at troubleshooting package errors. Since I'm not directly experiencing these errors, it is double-difficult to troubleshoot. Any help is appreciated.
Best,
Shawn
It is difficult to judge from these errors, what actually happens. Still, my conjecture is broken or incomplete R installations.
When using R on Windows, please double-check that you installed
1) a single version of R
2) Rtools giving compilers to R
Without Rtools, R will only function in a very limited sense as it cannot compile packages and depends on binary packages that might have been compiled with different versions of R on different platforms.
If these two ideas don't solve the problem and as you are teaching, please think about using a single VM or Docker image (my approach in teaching) such that you and all your students have exactly the same software platform. With this approach, you can use a stable Linux, where R is integrated and well-tested.
Overview
I think - because without each of your student's sessionInfo() output I am only able to make recommendations based off their error messages - the following will help:
Alex: install.packages( pkgs = c("digest", "rapportools") ).
Zoey & Aroun: install.packages( pkgs = "stringr" ).
Afterwards, have all three run install.packages( pkgs = "summarytools" ).
If all else fails, you can have all three run the following commands to install the package from GitHub: install.packages("devtools") followed by devtools::install_github("dcomtois/summarytools").
Methodology
I installed summarytools with the following command install.packages( pkgs = "summarytools" ). All of your students did the same, which led me to print out my session information using sessionInfo():
R version 3.4.3 (2017-11-30)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux
Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] summarytools_0.8.2
loaded via a namespace (and not attached):
[1] Rcpp_0.12.16 matrixStats_0.53.1 codetools_0.2-15 digest_0.6.14 bitops_1.0-6
[6] plyr_1.8.4 magrittr_1.5 stringi_1.1.7 pryr_0.1.4 rapportools_1.0
[11] tools_3.4.3 stringr_1.3.0 pander_0.6.1 RCurl_1.95-4.10 rsconnect_0.8.8
[16] compiler_3.4.3 htmltools_0.3.6
Based on the error messages from each of your students, the installation of summarytools seems to be failing due to dependency packages (i.e. rapportools, digest, and stringr) not downloading with their download of summarytools.
This is an updated answer
For Alex's problem, I suspect the apostrophe in the path ("Alex's PC") might be the culprit.
For Zoey's and Aroun's, it's not clear, maybe some permission issues...?
Possible solutions (for all three cases)
1 - Preferably, try installing through Github:
install.packages('devtools') # if not already installed
library(devtools)
install_github("dcomtois/summarytools")
2 - If solution 1 fails or is not possible for whatever reason, install the latest binaries instead of the most recent (source) version.
install.packages('summarytools', type = 'binary')
3- If all that fails, I'd suggest trying this prior to installation as a last resort. Normally this shouldn't be necessary, but it can't hurt. After completion, try regular install or one of the two previous solutions.
install.packages(c('htmltools', 'matrixStats', 'pander', 'pryr',
'rapportools', 'RCurl', 'Hmisc', 'rstudioapi',
'rmarkdown', 'stringr'))
install.packages('knitr', dependencies = TRUE)
update.packages(ask = FALSE, repos = 'https://cran.rstudio.org')

How to deal with: Error: could not find function "read_csv"

I installed the package readr and tried to upload a .csv file in Rstudio.
When I try to load this package I get the following error:
> library(readr)
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()),
versionCheck = vI[[j]]) : there is no package called ‘hms’ In addition:
Warning message: Paket ‘readr’ wurde unter R Version 3.2.5 erstellt
Error: Laden von Paket oder Namensraum für ‘readr’ fehlgeschlagen
When I try to upload the .csv file in R I get the error:
> dataX<-read_csv("file.csv")
Error: could not find function "read_csv"
The result of sessionInfo() is:
> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252
[3] 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] colorspace_1.3-2 scales_0.4.1 R6_2.2.2 lazyeval_0.2.0 plyr_1.8.4
[6] tools_3.2.2 gtable_0.2.0 tibble_1.3.0 Rcpp_0.12.10 ggplot2_2.2.1
[11] grid_3.2.2 munsell_0.4.3
I will appreciate your help. Thanks.
Ok, I was able to duplicate the problem on Windows. How and Why?
Resolution - Install R3.4.4
How
Install R3.4.4
Install Rtools3.4.
Launch R
> install.packages("readr")
Why?
The issue here (appears to be) that readr and the TidyVerse packages require later versions of R than R3.2.2. and the WIndows Rtools you have. I was able to duplicate the issue described by installing R3.2.2 and RTools3.2 and then trying to instal readr.
I did not encounter the error on installation of R3.4.4.
Background on Upgrading R on Windows:
You can install multiple versions of R (Base environment) and R Tools (Development environment) on Windows. My personal recommendation is to uninstall R, install the new versions of R, then install the latest R Tools and copy over the libraries per Windows faq below.
R Windows FAQ
2.8 What’s the best way to upgrade?
That’s a matter of taste. For most people the best thing to do is to uninstall R (see the previous Q), install the new version, copy any installed packages to the library folder in the new installation, run update.packages(checkBuilt=TRUE, ask=FALSE) in the new R and then delete anything left of the old installation. Different versions of R are quite deliberately installed in parallel folders so you can keep old versions around if you wish.
For those with a personal library (folder R\win-library\x.y of your home directory, R\win64-library\x.y on 64-bit builds), you will need to update that too when the minor version of R changes (e.g. from 3.0.2 to 3.1.0). A simple way to do so is to copy (say) R\win-library\3.0 to R\win-library\3.1 before running update.packages(checkBuilt=TRUE, ask=FALSE).
I too had the similar problem and re-installing package "tidyverse" did the trick for me while I was already on 3.4.4 version of R.
For me, it was loading tidyverse into the environment that did the trick. Load both tidyverse and dplyr

Error installing packages in RStudio: error reading from connection

I have recently updated both R (version 3.4.1) and RStudio (version 1.0.143) and I am now unable to install packages from Rstudio.
If I install a package in R directly using install.packages() it works fine.
If I try and install a package in Rstudio using either install.packages() or using the package install menu I get the error below. I have tried a few different packages, and have uninstalled and reinstalled both R and RStudio.
To get the error:
Run:
install.packages("lme4")
Output:
Installing package into ‘E:/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
also installing the dependencies ‘minqa’, ‘nloptr’, ‘RcppEigen’
Warning in install.packages :
lzma decoding result 10
Error in install.packages : error reading from connection
I am working off my personal computer, below is some of my system info:
Output from options("repos")
$repos
CRAN CRANextra
"https://cran.stat.auckland.ac.nz/" "http://www.stats.ox.ac.uk/pub/RWin"
attr(,"RStudio")
[1] TRUE
Output from sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_New Zealand.1252 LC_CTYPE=English_New Zealand.1252
LC_MONETARY=English_New Zealand.1252
[4] LC_NUMERIC=C LC_TIME=English_New Zealand.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.4.1 tools_3.4.1
This certainly is an issue with your connection:the proxies you are using and repositories configured in your RStudio. I was getting the same error when I was connected to US VPN from India.I disconnected VPN and restarted RStudio and it worked like a charm!
I had the same issue when I tried to install caret.
The best solution is to restart R studio.
Now the install.packages() works fine.
Just restart the R studio it works for me.
I had the same issue after I misspelled a package name when trying to install it. I restarted R Studio and then it worked.
Kindly select appropriate CRAN mirror in R Studio through following option:
Tools>>>Packages>>>CRAN Mirror(Select appropriate CRAN depending on your location).
A simple solution would be to download manually the zip folder of the package and install it with the command :
install.packages('package.zip', lib='destination_directory',repos = NULL)
Package zip : the path to the zip file of the package
Destination_directory: where the packages are installed by default like C:/Users/unknown/Documents/R/win-library/3.3
Hope it helps

installing e1071 in R on ubuntu interface

I am unable to install e1071 on my ubuntu machine.
I tried using:
sudo apt-get install r-cran-e1071
gives an error message:
Warning messages:
1: In open.connection(con, "r") :
unable to connect to 'cran.r-project.org' on port 80.
2: E: Unable to locate package r-cran-e1071
and
install.packages("e1071", dep = TRUE, type = "source")
gives an error message:
package ‘e1071’ is not available (for R version 2.15.2)
sessionInfo() gives:
R version 2.15.2 (2012-10-26)
Platform: x86_64-pc-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_IN LC_NUMERIC=C LC_TIME=en_IN
[4] LC_COLLATE=en_IN LC_MONETARY=en_IN LC_MESSAGES=en_IN
[7] LC_PAPER=C LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_IN LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tcltk_2.15.2 tools_2.15.2
The package e1071 depends on package class. The package class depends on R (≥ 3.0.0). Hence, you should update to a more recent R version.
Like #SvenHohenstein already said, the package needs a different version of R. What you can do is get an old version of the package from its archives, but you'll probably have to install older versions of other packages. In addition, you'll have to build the old version of the package from source as no binary versions are archived. Simply updating to a new R version is much easier...

Error in library(functional) : there is no package called ‘functional’ - While running MR using rmr2

I am trying to run a simple MR program using rmr2 in a single node Hadoop cluster. Here is the environment for the setup
Ubuntu 12.04 (32 bit)
R (Ubuntu comes with 2.14.1, so updated to 3.0.2)
Installed the latest rmr2 and rhdfs from here and the corresponding dependencies
Hadoop 1.2.1
Now I am trying to run a simple MR program as
Sys.setenv(HADOOP_HOME="/home/training/Installations/hadoop-1.2.1")
Sys.setenv(HADOOP_CMD="/home/training/Installations/hadoop-1.2.1/bin/hadoop")
library(rmr2)
library(rhdfs)
ints = to.dfs(1:100)
calc = mapreduce(input = ints, map = function(k, v) cbind(v, 2*v))
from.dfs(calc)
The mapreduce job fails with the below error message in hadoop-1.2.1/logs/userlogs/job_201310091055_0001/attempt_201310091055_0001_m_000000_0/stderr
Error in library(functional) : there is no package called ‘functional’
Execution halted
java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1
at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:362)
at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:576)
But, the sessionInfo() shows that functional package has been loaded
> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: i686-pc-linux-gnu (32-bit)
>locale:
[1] LC_CTYPE=en_IN LC_NUMERIC=C LC_TIME=en_IN
[4] LC_COLLATE=en_IN LC_MONETARY=en_IN LC_MESSAGES=en_IN
[7] LC_PAPER=en_IN LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_IN LC_IDENTIFICATION=C
>attached base packages:
[1] stats graphics grDevices utils datasets methods base
>other attached packages:
[1] rhdfs_1.0.6 rJava_0.9-4 rmr2_2.3.0 reshape2_1.2.2 plyr_1.8
[6] stringr_0.6.2 **functional_0.4** digest_0.6.3 bitops_1.0-6 RJSONIO_1.0-3
[11] Rcpp_0.10.5
Update : I am able to run a R MR job reading and writing from STDIO without using the rmr2 and the rhdfs libraries as mentioned here. So, for now my guess is that the problem is isolated to rmr2 and the rhdfs packages.
How to get around this problem?
Install the dependencies for rmr2/rhdfs in a system directory instead of a custom directory (~/R/x86_64-pc-linux-gnu-library/3.0). This can be done running R as sudo and then installing the dependencies. Thanks to Antonio for the help in the RHadoop forums.
The most common solution of these kind of problem is re-installation since in sesssionInfo()
you are getting
**functional_0.4**
while when i did sessionInfo() i got
functional_0.4
i guess there is some missing dependencies you might be missing so use from your R console
install.packages("functional",dependencies="TRUE")
to fix any problem due to any other packages .
P.S: Choose cloud-0 mirror from the available ones.
If still that does not help i recommend you use r-base-dev as your R version though i don't have a reason to justify this using http://cran.r-project.org/bin/linux/ubuntu/README
sudo apt-get install r-base-dev
Thanks

Resources