Why can't install tidymodels package in Jupyter notebook? - r

My Rstudio is 4.0.4 version, however, it showed that the package was built under R verision 3.6.3.
And I can not use this package. How to solove this problem?
library(tidymodels)
Warning message:
"package 'tidymodels' was built under R version 3.6.3"
Error: package or namespace load failed for 'tidymodels' in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
namespace 'recipes' 0.1.5 is being loaded, but >= 0.1.16 is required
Traceback:
1. library(tidymodels)
2. tryCatch({
. attr(package, "LibPath") <- which.lib.loc
. ns <- loadNamespace(package, lib.loc)
. env <- attachNamespace(ns, pos = pos, deps, exclude, include.only)
. }, error = function(e) {
. P <- if (!is.null(cc <- conditionCall(e)))
. paste(" in", deparse(cc)[1L])
. else ""
. msg <- gettextf("package or namespace load failed for %s%s:\n %s",
. sQuote(package), P, conditionMessage(e))
. if (logical.return)
. message(paste("Error:", msg), domain = NA)
. else stop(msg, call. = FALSE, domain = NA)
. })
3. tryCatchList(expr, classes, parentenv, handlers)
4. tryCatchOne(expr, names, parentenv, handlers[[1L]])
5. value[[3L]](cond)
6. stop(msg, call. = FALSE, domain = NA)

That's a warning. The actual error shows beneath:
Error: package or namespace load failed for 'tidymodels' in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
namespace 'recipes' 0.1.5 is being loaded, but >= 0.1.16 is required
And it is very clear: you need a more recent version of recipes which you can get through install.packages. It could be that a newer version of the package is not available for your R version, in which case you'll need to install RTools (assuming windows, otherwise not required) and do an installation from source.

Related

There is no package called 'foreign'

I'm trying to install the package 'Hmisc' in R but I'm running into an error, shown below:
Error: package or namespace load failed for 'Hmisc' in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called 'foreign'
Traceback:
1. library(Hmisc)
2. tryCatch({
. attr(package, "LibPath") <- which.lib.loc
. ns <- loadNamespace(package, lib.loc)
. env <- attachNamespace(ns, pos = pos, deps, exclude, include.only)
. }, error = function(e) {
. P <- if (!is.null(cc <- conditionCall(e)))
. paste(" in", deparse(cc)[1L])
. else ""
. msg <- gettextf("package or namespace load failed for %s%s:\n %s",
. sQuote(package), P, conditionMessage(e))
. if (logical.return)
. message(paste("Error:", msg), domain = NA)
. else stop(msg, call. = FALSE, domain = NA)
. })
3. tryCatchList(expr, classes, parentenv, handlers)
4. tryCatchOne(expr, names, parentenv, handlers[[1L]])
5. value[[3L]](cond)
6. stop(msg, call. = FALSE, domain = NA)
I've looked around and can't seem to find any answers.

How to adjust Jupyter Notebook "R" error?

I'm getting the below error when trying to import library & I'm using R in Jupyter Notebook.
library(ggpubr)
Warning message:
"package 'ggpubr' was built under R version 3.6.3"
Error: package or namespace load failed for 'ggpubr' in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
namespace 'rlang' 0.4.2 is already loaded, but >= 0.4.5 is required
Traceback:
1. library(ggpubr)
2. tryCatch({
. attr(package, "LibPath") <- which.lib.loc
. ns <- loadNamespace(package, lib.loc)
. env <- attachNamespace(ns, pos = pos, deps, exclude, include.only)
. }, error = function(e) {
. P <- if (!is.null(cc <- conditionCall(e)))
. paste(" in", deparse(cc)[1L])
. else ""
. msg <- gettextf("package or namespace load failed for %s%s:\n %s",
. sQuote(package), P, conditionMessage(e))
. if (logical.return)
. message(paste("Error:", msg), domain = NA)
. else stop(msg, call. = FALSE, domain = NA)
. })
3. tryCatchList(expr, classes, parentenv, handlers)
4. tryCatchOne(expr, names, parentenv, handlers[[1L]])
5. value[[3L]](cond)
6. stop(msg, call. = FALSE, domain = NA)
I have tried the below codes to adjust it ,But it didn't workout
remove.packages("ggpubr")
&
install.packages("ggpubr")
&
update.packages(Yes)

macOS fresh install of R - devtools are giving segfault error -

I've done a fresh reinstall of R 3.6 on a macOS Mojava v 10.14.6
I've install clang 7 here from the provided installer /usr/local/clang7
I have xcode
But there's something wrong with the install that I can seem to figure out
.libPaths()
[1] "/Users/annaleigh/Library/R/3.6/library"
[2] "/Library/Frameworks/R.framework/Versions/3.6/Resources/library"
> install.packages("devtools")
Installing package into ‘/Users/annaleigh/Library/R/3.6/library’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/bin/macosx/el-capitan/contrib/3.6/devtools_2.2.1.tgz'
Content type 'application/x-gzip' length 339075 bytes (331 KB)
==================================================
downloaded 331 KB
The downloaded binary packages are in
/var/folders/xr/lmkkh0p10t948k1n104z1jsh0000gn/T//Rtmpf54J79/downloaded_packages
> library(devtools)
\Loading required package: usethis
*** caught segfault ***
address 0x2c2e0, cause 'memory not mapped'
However the usethis library seem to load fine
> library(usethis)
> library(devtools)
*** caught segfault ***
address 0x2c2e0, cause 'memory not mapped'
Traceback:
1: dyn.load(file, DLLpath = DLLpath, ...)
2: library.dynam(lib, package, package.lib)
3: loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]])
4: asNamespace(ns)
5: namespaceImportFrom(ns, loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]), i[[2L]], from = package)
6: loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]])
7: asNamespace(ns)
8: namespaceImportFrom(ns, loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]), i[[2L]], from = package)
9: loadNamespace(package, lib.loc)
10: doTryCatch(return(expr), name, parentenv, handler)
11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
12: tryCatchList(expr, classes, parentenv, handlers)
13: tryCatch({ attr(package, "LibPath") <- which.lib.loc ns <- loadNamespace(package, lib.loc) env <- attachNamespace(ns, pos = pos, deps, exclude, include.only)}, error = function(e) { P <- if (!is.null(cc <- conditionCall(e))) paste(" in", deparse(cc)[1L]) else "" msg <- gettextf("package or namespace load failed for %s%s:\n %s", sQuote(package), P, conditionMessage(e)) if (logical.return) message(paste("Error:", msg), domain = NA) else stop(msg, call. = FALSE, domain = NA)})
14: library(devtools)
Answer found here:
https://github.com/r-lib/devtools/issues/1292
"Finally looked at .libPath() and realized that both instances of R were looking at the user library before the system library. So if the packages were linked to different system libraries from the compiled versions (OS X Sierra and El Capitan in my case) this could create the seg fault.
Removing libraries in the user library ~/user/Library/R/version# fixed the issue (with installing to different locations)"

Why is R crashing when I try to import certain packages?

Anytime I have tried to import a package in R, it ends up crashing. To illustrate, if I run a command such as library(broom) in my terminal, the following error is yielded:
*** caught segfault ***
address 0x18, cause 'memory not mapped'
Traceback:
1: dyn.load(file, DLLpath = DLLpath, ...)
2: library.dynam(lib, package, package.lib)
3: loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]])
4: namespaceImport(ns, loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]), from = package)
5: loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]])
6: namespaceImport(ns, loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]), from = package)
7: loadNamespace(package, lib.loc)
8: doTryCatch(return(expr), name, parentenv, handler)
9: tryCatchOne(expr, names, parentenv, handlers[[1L]])
10: tryCatchList(expr, classes, parentenv, handlers)
11: tryCatch({ attr(package, "LibPath") <- which.lib.loc ns <- loadNamespace(package, lib.loc) env <- attachNamespace(ns, pos = pos, deps)}, error = function(e) { P <- if (!is.null(cc <- conditionCall(e))) paste(" in", deparse(cc)[1L]) else "" msg <- gettextf("package or namespace load failed for %s%s:\n %s", sQuote(package), P, conditionMessage(e)) if (logical.return) message(paste("Error:", msg), domain = NA) else stop(msg, call. = FALSE, domain = NA)})
12: library(broom)
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
This error is followed by my R crashing in my terminal. Furthermore, this result replicated within RStudio, and the whole program must be reopened if I try to import packages. Interestingly, not all packages behave the same way. When I import a basic package such as library(stats) or library(base), it works fine.
I have tried to uninstall R, Rstudio, and relevant R packages from my computer and then reinstall them (as per https://support.rstudio.com/hc/en-us/community/posts/115007714568-Latest-version-of-Rstudio-rmarkdown-causing-abort-on-R-version-3-4-0-for-x86-64-apple-darwin15-6-0-64-bit-), but with no success. Is this a problem that is related to the setup of my PATH variable?
For the record, I am running R-3.4 on Mac OSX-10.12 Sierra.
UPDATE
This might not be that important, but I decided to look around and see where my packages were installed by putting them all in a dataframe in R (ip<-as.data.frame(installed.packages())), and I noticed that my packages are stored in two different file paths– either /Users/bob/Library/R/3.4/library, or /Library/Frameworks/R.framework/Versions/3.4/Resources/library. Does anybody think this discrepancy is the cause for my R crashing all the time?
After figuring out that I had installed packages downloaded to two different libraries (see Update section in question above), I decided to remove all packages that I had installed. Using this source (https://www.r-bloggers.com/how-to-remove-all-user-installed-packages-in-r/) as my guide, I carried out the following commands:
ip <- as.data.frame(installed.packages())
ip <- ip[!(ip[,"Priority"] %in% c("base", "recommended")),]
ip <- subset(ip, !grepl("MRO", ip$LibPath))
path.lib <- unique(ip$LibPath)
pkgs.to.remove <- ip[,1]
sapply(pkgs.to.remove, remove.packages, lib = path.lib)
Furthermore, I also removed any remaining packages in the folder Users/bob/Library/R/3.4/library, and then I set only one of my libraries as the default library where installed packages were downloaded to:
.libPaths("/Library/Frameworks/R.framework/Versions/3.4/Resources/library")
And then ran .libPaths() again to make sure that this file path was the first that got printed. I then carried out install.packages("NameOfDesiredPackage") on any of the packages I wanted, and when I imported them into my console or terminal, they imported with no problem.

Error with ggplot2 after installing new R

I wanted to install a new version of R.
I downloaded R-3.1.0.pkg and installed it.
I mved my packages from ~/Library/R/3.0 to ~/Library/R/3.1
the new R starts, but when I try to load some packages, I get an error.
This seems to be due to ggplot2. As I can load any package that doesn't depend on ggplot2.
I just reinstalled ggplot2 using install.packges(), but still no luck. R just crashes when I try to load the library.
I performed update.packages(). Is this related to how I migrated my packages?
Also, I seem to have packages in multiple places. Although I think RStudio seems to install all of them in the ~/Library/Frameworks/R.framework/Versions/3.1/Resources/library
thanks
> library(Hmisc)
Loading required package: grid
Loading required package: lattice
Loading required package: survival
Loading required package: Formula
Loading required package: ggplot2
*** caught segfault ***
address 0x18, cause 'memory not mapped'
Traceback:
1: dyn.load(file, DLLpath = DLLpath, ...)
2: library.dynam(lib, package, package.lib)
3: loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]])
4: namespaceImport(ns, loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]), from = package)
5: loadNamespace(package, c(which.lib.loc, lib.loc))
6: doTryCatch(return(expr), name, parentenv, handler)
7: tryCatchOne(expr, names, parentenv, handlers[[1L]])
8: tryCatchList(expr, classes, parentenv, handlers)
9: tryCatch(expr, error = function(e) { call <- conditionCall(e) if (!is.null(call)) { if (identical(call[[1L]], quote(doTryCatch))) call <- sys.call(-4L) dcall <- deparse(call)[1L] prefix <- paste("Error in", dcall, ": ") LONG <- 75L msg <- conditionMessage(e) sm <- strsplit(msg, "\n")[[1L]] w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w") if (is.na(w)) w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L], type = "b") if (w > LONG) prefix <- paste0(prefix, "\n ") } else prefix <- "Error : " msg <- paste0(prefix, conditionMessage(e), "\n") .Internal(seterrmessage(msg[1L])) if (!silent && identical(getOption("show.error.messages"), TRUE)) { cat(msg, file = stderr()) .Internal(printDeferredWarnings()) } invisible(structure(msg, class = "try-error", condition = e))})
10: try({ ns <- loadNamespace(package, c(which.lib.loc, lib.loc)) env <- attachNamespace(ns, pos = pos, deps)})
11: library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc)
12: .getRequiredPackages2(pkgInfo, quietly = quietly)
13: library(Hmisc

Resources