Install "gradethis" package for code checking in "learnr" - r

I am creating the interactive tutorials for R for presentation using "learnr" package. For code checking, I need the package "gradethis". When I try to install this package by
"
remotes::install_github("rstudio-education/gradethis")
"
it gives the error message:
.
.
.
** byte-compile and prepare package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
namespace ‘learnr’ 0.10.1 is being loaded, but >= 0.10.1.9007 is required
ERROR: lazy loading failed for package ‘gradethis’
─ removing ‘/private/var/folders/r2/3nmkgqc51q54tmhxl00tsk2908fpk9/T/RtmpaPONJB/Rinst15003850258d/gradethis’
-----------------------------------
ERROR: package installation failed
Error: Failed to install 'gradethis' from GitHub:
.
.
.
The error message shows "‘learnr’ 0.10.1 is being loaded, but >= 0.10.1.9007 is required", however on CRAN, 0.10.1 is the latest version:
https://cran.r-project.org/web/packages/learnr/index.html
Can anyone help for this case? Many thanks.
The following show sessionInfo()
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/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_3.5.1 rjson_0.2.20 plyr_1.8.6
[4] markdown_1.1 htmltools_0.5.1.9000 tools_3.5.1
[7] base64enc_0.1-3 yaml_2.2.1 Rcpp_1.0.6
[10] rmarkdown_2.6 knitr_1.31 xfun_0.20
[13] digest_0.6.27 tutorial_0.4.3 rlang_0.4.10.9000
[16] evaluate_0.14

Since gradethis is still in a developmental/experimental phase, it is currently only available through GitHub at rstudio/gradethis. gradethis currently requires the developmental version of learnr which is also not yet on CRAN.
Installing both packages from their GitHub repositories will likely resolve your issues:
# install.packages("remotes") # require {remotes}
remotes::install_github("rstudio/learnr")
remotes::install_github("rstudio/gradethis")
Edit: The gradethis repository is now hosted under the rstudio GitHub organization.

Reproduced the error (macOS Big Sur 11.1 / Rstudio 1.3.1093 / R version 4.0.3) and solved the issue by uninstalling learnr with remove.packages("learnr") then installing gradethis with dependencies (including the required version of learnr) using remotes::install_github("rstudio-education/gradethis").
If you get a warning that "Skipping install of 'gradethis' from a github remote, the SHA1 has not changed since last install", use the command remotes::install_github("rstudio-education/gradethis", force = TRUE)
Successfully installing the packages requires the ability to compile from source (instructions for macOS Big Sur: https://stackoverflow.com/a/65334247/12957340)

Related

R devtools unable to install - Ubuntu 20.04 - package or namespace load failed for ‘pkgload’

I am pretty desperate to install.packages("devtools").
However it allways fails with this error
Error: .onLoad failed in loadNamespace() for 'pkgload', details:
call: readRDS(nsInfoFilePath)
error: error reading from connection
Execution halted
ERROR: lazy loading failed for package ‘devtools’
* removing ‘/home/bjoern/R/x86_64-pc-linux-gnu-library/3.6/devtools’
Things I tried to fix this:
Add the dependencies = T argument
Following a suggestion by hadley wickham on github -> update rlang package
Try to run install.packages("pkgload") resulting in nearly exactly the same error (see below)
Completely removing R and reinstalling it
Additionally installing package following packages:
r-base-dev
r-cran-devtools
r-recommended
Updated all packages update.packages(ask = FALSE, checkBuilt = TRUE)
Error of install.packages("pkgload")
Error: package or namespace load failed for ‘pkgload’:
.onLoad failed in loadNamespace() for 'pkgload', details:
call: readRDS(nsInfoFilePath)
error: error reading from connection
Error: loading failed
Execution halted
ERROR: loading failed
I digged even deeper to the pkgload (which at least I hope is the only reason for the problem). I will check if manually (re)installing all imports and suggests from the CRAN page of pkgload does solve it.
Imports: desc, methods, pkgbuild, rlang, rprojroot, rstudioapi,
utils, withr Suggests: bitops, covr, Rcpp, testthat
My sessionInfo() output:
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=de_DE.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=de_DE.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=de_DE.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.6.3 tools_3.6.3
I still refuse to belief that it is impossibe to install devtools on ubuntu20
However at this point I take any straw
Solution Edit:
In short what fixed the issue for me was installing testthat package before. Thanks to comment by rui-barradas
install.packages("testthat")
install.packages("pkgload")
install.packages("devtools")
I am also on Ubuntu 20.04 but running R 4.0.0.
When trying to install a package, if it depends on another that was installed prior to R 4.0.0 I get an error message and the installation fails. This happens even if I set dependencies = TRUE in the call to install.packages.
Example: The command was
install.packages('pkgload')
I omit the first output lines, saying that the file was downloaded. Then, the relevant part.
installing source package ‘pkgload’ ...
** package ‘rcmdcheck’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** byte-compile and prepare package for lazy loading Error: package ‘testthat’ was installed before R 4.0.0: please re-install it
Execution halted ERROR: lazy loading failed for package ‘pkgload’
removing ‘/usr/local/lib/R/site-library/pkgload’
restoring previous ‘/usr/local/lib/R/site-library/pkgload’ Warning in install.packages : installation of package ‘pkgload’ had
non-zero exit status The downloaded source packages are in
‘/tmp/RtmpVxpbs0/downloaded_packages’
Correct way.
The right way of installing package pkgload was to run the sequence
install.packages('testthat')
install.packages('pkgload')
and the problem was solved.
Note that with other packages, it already happened to see this be a recursive issue. Imagine that package testthat depended (which it does not) on another package installed prior to R 4.0.0.
Annoying but solvable.
sessionInfo()
#R version 4.0.0 (2020-04-24)
#Platform: x86_64-pc-linux-gnu (64-bit)
#Running under: Ubuntu 20.04 LTS
#
#Matrix products: default
#BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
#LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
#
#locale:
# [1] LC_CTYPE=pt_PT.UTF-8 LC_NUMERIC=C
#[3] LC_TIME=pt_PT.UTF-8 LC_COLLATE=pt_PT.UTF-8
# [5] LC_MONETARY=pt_PT.UTF-8 LC_MESSAGES=pt_PT.UTF-8
# [7] LC_PAPER=pt_PT.UTF-8 LC_NAME=C
# [9] LC_ADDRESS=C LC_TELEPHONE=C
#[11] LC_MEASUREMENT=pt_PT.UTF-8 LC_IDENTIFICATION=C
#
#attached base packages:
#[1] stats graphics grDevices utils datasets
#[6] methods base
#
#other attached packages:
#[1] rvest_0.3.5 xml2_1.3.2 data.table_1.12.8
#
#loaded via a namespace (and not attached):
I had the same problems, and the solution was, at least in my case, Ubuntu 20.04.1 LTS (Focal Fossa) + R 4.0.2:
First (from terminal), install:
Step 1: sudo apt-get update -y
Step 2: sudo apt-get install -y libxml2-dev
Then from RStudio (setRepositories first, and choose 8 repositories) and install both packages:
Install xml2 package
install devtools
And works for me.

Installing dplyr in R version 3.2.1

Cannot install dplyr in a R 3.2.1 version. I tried everything, I downloaded a previous version of dplyr in the laptop (0.4.2), I tried from other mirrors, but still cannot get it installed. The same with "tidyverse"
When I try it locally it says:
installing source package ‘dplyr’ ...
** package ‘dplyr’ successfully unpacked and MD5 sums checked
** libs sh: make: command not found ERROR: compilation failed for package ‘dplyr’
removing ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/dplyr’
restoring previous ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/dplyr’
Warning in install.packages : installation of package
‘/Users/x/Desktop/Master/R/dplyr_0.4.0.tar.gz’ had non-zero exit statu
That's the local error.
The online version of installing it says
it cannot be installed
my sessioninfo
R version 3.2.1 (2015-06-18) Platform: x86_64-apple-darwin10.8.0 (64-bit) Running under: OS X 10.8.5 (Mountain Lion) locale: [1] es_ES.UTF-8/es_ES.UTF-8/es_ES.UTF-8/C/es_ES.UTF-8/es_ES.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] remotes_2.0.4 loaded via a namespace (and not attached): [1] httr_1.4.0 R6_2.4.0 tools_3.2.1 RCurl_1.95-4.8 digest_0.6.10 bitops_1.0-6
Thanks!

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

Package dependency error "there is no package called ‘stringi’"

I created an R package and loaded it to github (microdadosBrasil). When I try to install the package (as a user would) I get the following error:
devtools::install_github("lucasmation/microdadosBrasil")
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
there is no package called ‘stringi’
I tried solving this by adding stringi to the package dependencies
In DESCRIPTION in included:
Imports:
stringi
I also included the package import at NAMESPACE
import(stringi)
But, even then I get the same installation error.
To be hones I'm not even aware of any explicit function in my package that uses the stringi package.
If I install stringi before then the microdadosBrasil installation works:
install.packages('stringi')
devtools::install_github("lucasmation/microdadosBrasil")
This is the session information when error occurs (before pre-installing stringi)
sessionInfo()
R version 3.1.3 (2015-03-09)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=Portuguese_Brazil.1252 LC_CTYPE=Portuguese_Brazil.1252
[3] LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C
[5] LC_TIME=Portuguese_Brazil.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tools_3.1.3
The problem is due to dependencies of packages because one package calls file in another package and so on (like recursion). So first try to install all dependencies of the package then definitely this package will work.

R asking for unknown dependency when loading package

I'm the maintainer for the package 'rase' (link).
I haven't changed the code at all since Nov 9, 2015, when the package could load without problems. However, I have received emails asking about the following problem when loading the package:
> library(rase)
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘Biostrings’
Error: package or namespace load failed for ‘rase’
I tried then to do it in my own computer, and I received the same message. Between the last time I loaded the package successfully (Nov 2015) and now, I upgraded R to v 3.2.3. Naively, I reinstalled v3.2.2, but the same error appears. I have checked rase code (git here) thoroughly, but no changes have been made and there is no reference whatsoever to 'Biostrings' (or any function within). 'rase' dependencies and imports do not include 'Biostrings'.
Any help would be much appreciated as I don't know why this is happening (I'm a novice when creating packages). I guess I could install 'Biostrings', but I don't want to make a seemingly unnecessary dependency.
Here is my sessionInfo:
> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.2 (El Capitan)
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
other attached packages:
[1] ape_3.4 data.table_1.9.6
loaded via a namespace (and not attached):
[1] quadprog_1.5-5 lattice_0.20-33 mvtnorm_1.0-3 msm_1.6
[5] MASS_7.3-43 chron_2.3-47 grid_3.2.2 nnls_1.4
[9] nlme_3.1-121 magrittr_1.5 Matrix_1.2-2 splines_3.2.2
[13] tools_3.2.2 igraph_1.0.1 maps_3.0.2 parallel_3.2.2
[17] numDeriv_2014.2-1 survival_2.38-3 mnormt_1.5-3 clusterGeneration_1.3.4
[21] animation_2.4 expm_0.999-0
Biostrings is a BioConductor package which you install following the instructions on this page:
## try http:// if https:// URLs are not supported
source("https://bioconductor.org/biocLite.R")
biocLite("Biostrings")
If you add BioC as a known repository on your system, it will be installable via install.packages() too. Eg this would do
r <- getOption("repos")
r["CRAN"] <- "http://cran.rstudio.com"
r["BioCsoft"] <- "http://www.bioconductor.org/packages/release/bioc"
options(repos = r)
in your .Rprofile or Rprofile.site.

Resources