Errors installing "dplyr" in r - r

Question: unable to install dplyr in R... code below. Anyone offer any solutions?
I'm on a mac osx sierra and R Version 1.0.136
> install.packages("dplyr")
There is a binary version available but the source version
is later:
binary source needs_compilation
dplyr 0.5.0 0.7.0 TRUE
Do you want to install from sources the package which needs compilation?
y/n:
y
installing the source package ‘dplyr’
trying URL 'https://cran.rstudio.com/src/contrib/dplyr_0.7.0.tar.gz'
Content type 'application/x-gzip' length 690938 bytes (674 KB)
==================================================
downloaded 674 KB
* installing *source* package ‘dplyr’ ...
** package ‘dplyr’ successfully unpacked and MD5 sums checked
** libs
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
ERROR: compilation failed for package ‘dplyr’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/dplyr’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/dplyr’
Warning in install.packages :
installation of package ‘dplyr’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/ll/6vx1dr1n5bb9zwbv1z9v53z00000gn/T/RtmpitMpQn/downloaded_packages’
> library(dplyr)
Error: package or namespace load failed for ‘dplyr’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
there is no package called ‘DBI’
Not sure why this isn't working! Tried to download manually and it didn't work either (similar/same warnings/errors)

A new dplyr version was accepted into CRAN yesterday. Usually CRAN provides packages for both Windows and OSX in binary form, but it takes up to 48 hours for CRAN to provide the compiled packages.
When you try to install a package in that time window, R asks you to either install the previous binary version or the new version from source. If you decide to install the version from source you will need to have a c++ compiler.
The easiest thing for you to do is to either install the previous binary package or wait until the latest version gets compiled at CRAN.
Checkout https://cran.r-project.org/web/packages/dplyr/index.html to see if the binaries for your OS are already available.
Update: It seems there are some issues with the latest dplyr version, and the OSX compilation seems to fail. More info here: https://cran.r-project.org/web/checks/check_results_dplyr.html. I would rather stay with 0.5.0 until those issues are ironed out.

Related

Unable to install any package in computer at my office, how to fix?

I'm trying to use computer in my office for working using Rstudio because I realised that there is Rstudio installed in the computer. However, when I'm trying to install the package I need, the package is unable to install. I try so many package but the same issue happen.Even though, I'm trying to update installed package such as rlang version 1.02 to the latest one, it is also failed. I've tried to restart Rstudio as well after I installed the package, but I can't find the package that I have installed before.
Here is the error message that I receive when I try to install the very standard one such as scales package:
install.packages("scales")
also installing the dependencies ‘rlang’, ‘lifecycle’
There are binary versions available but the source versions are later:
binary source needs_compilation
rlang 1.0.2 1.0.6 TRUE
lifecycle 1.0.1 1.0.2 FALSE
scales 1.2.0 1.2.1 FALSE
Binaries will be installed
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/rlang_1.0.2.zip'
Content type 'application/zip' length 1718546 bytes (1.6 MB)
downloaded 1.6 MB
package ‘rlang’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\axk1076\AppData\Local\Temp\RtmpYjc7m3\downloaded_packages
installing the source packages ‘lifecycle’, ‘scales’
trying URL 'https://cran.rstudio.com/src/contrib/lifecycle_1.0.2.tar.gz'
Content type 'application/x-gzip' length 102178 bytes (99 KB)
downloaded 99 KB
trying URL 'https://cran.rstudio.com/src/contrib/scales_1.2.1.tar.gz'
Content type 'application/x-gzip' length 270609 bytes (264 KB)
downloaded 264 KB
'\\adf\storage\A\K\AXK1076'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
* installing *source* package 'lifecycle' ...
** package 'lifecycle' successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
namespace 'rlang' 1.0.2 is being loaded, but >= 1.0.5 is required
Calls: <Anonymous> ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace
Execution halted
ERROR: lazy loading failed for package 'lifecycle'
* removing 'C:/Program Files/R/R-4.0.3/library/lifecycle'
Warning in install.packages :
installation of package ‘lifecycle’ had non-zero exit status
'\\adf\storage\A\K\AXK1076'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
ERROR: dependency 'lifecycle' is not available for package 'scales'
* removing 'C:/Program Files/R/R-4.0.3/library/scales'
Warning in install.packages :
installation of package ‘scales’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\axk1076\AppData\Local\Temp\RtmpYjc7m3\downloaded_packages’
I don't know how Rstudio installed in this computer and I'm truly beginner in R. Is there anyone can help me? thank you in advance. Regards.
Since it is not known how R was installed in your computer, I would highly recommend you to uninstall both R and RStudio and installing the latest versions from the official websites.
First install R from: https://cran.r-project.org/bin/windows/base/
Install RStudio from: https://www.rstudio.com/products/rstudio/download/
Maybe they were installed in the wrong settings for your computer. Also to prevent bigger issues in the future (especially for beginners), that's the best option.

How to get out of the R dependency hell?

I have very weird dependency error on my R/R-studio environment after I updated the R-studio version from v1.2.5042 to the latest (v2022.02.2+485);
The problem is that when I try to load a package, some packages logs an error, as follows.
> library(plotly)
Error: package or namespace load failed for ‘plotly’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
namespace ‘htmlwidgets’ 1.5.1 is already loaded, but >= 1.5.2.9001 is required
In addition: Warning message:
package ‘plotly’ was built under R version 4.0.5
Umm, very weird. Because before I updated the R studio version at least for the plotly package, the importing command never logged an error similar to the above. I'm very confused.
(btw I updated the R studio version because 1. The old version was 2020's one, very old; 2. The plotly package didn't work well, for example it makes R-studio CPU 100% on the PC;)
So, I googled and found an SO post that mentions to the error, namespace xx is already loaded, but >= xx is required:
R install package loaded namespace - Stack Overflow
The answers say in this case I just need to re-install the error-mentioned package and reload it; So I did:
> install.packages("htmlwidgets")
Error in install.packages : Updating loaded packages
> install.packages("htmlwidgets")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/_documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/htmlwidgets_1.5.4.zip'
Content type 'application/zip' length 905152 bytes (883 KB)
downloaded 883 KB
package ‘htmlwidgets’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\user\AppData\Local\Temp\RtmpeCeZz2\downloaded_packages
Then
> library(htmlwidgets)
Warning message:
package ‘htmlwidgets’ was built under R version 4.0.5
And re-try to the command:
> library(plotly)
Error: package or namespace load failed for ‘plotly’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
namespace ‘rlang’ 0.4.6 is already loaded, but >= 0.4.10 is required
In addition: Warning message:
package ‘plotly’ was built under R version 4.0.5
Wow, a new package name pops up, ‘rlang’. This isn't right.
Anyways I tried to deal with the ‘rlang’ this time:
> install.packages("rlang")
Error in install.packages : Updating loaded packages
> install.packages("rlang")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/_documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/rlang_1.0.2.zip'
Content type 'application/zip' length 1718545 bytes (1.6 MB)
downloaded 1.6 MB
package ‘rlang’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\user\AppData\Local\Temp\RtmpeCeZz2\downloaded_packages
Then:
> library(rlang)
Error in value[[3L]](cond) :
Package ‘rlang’ version 0.4.6 cannot be unloaded:
Error in unloadNamespace(package) : namespace ‘rlang’ is imported by ‘htmltools’, ‘ellipsis’, ‘tidyr’, ‘purrr’, ‘ggplot2’, ‘tidyselect’, ‘vctrs’, ‘dplyr’, ‘tibble’, ‘lifecycle’, ‘pillar’ so cannot be unloaded
In addition: Warning message:
package ‘rlang’ was built under R version 4.0.5
Woah, I can't even load the dependency package this time. I'm sure something isn't right in my R and/or R-studio.
What's happening, and how can I solve this issue? I mean when simply updating R-studio and restarting doesn' work, what can I do? Thanks.
R.version:
> R.version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 4
minor 0.0
year 2020
month 04
day 24
svn rev 78286
language R
version.string R version 4.0.0 (2020-04-24)
nickname Arbor Day

Install/Compiling Errors with R Packages: tidyverse and caret

I recently had to install RStudio and the R language onto a new Macbook. It seemed to install the packages normally but when I started run some newly written code, the console would not execute tidyverse and caret even though it said it was downloaded. This is what shows up in the console and it's the same messages for both caret and tidyverse:
> install.packages("tidyverse")
trying URL 'https://cran.rstudio.com/bin/macosx/contrib/4.1/tidyverse_1.3.1.tgz'
Content type 'application/x-gzip' length 421072 bytes (411 KB)
==================================================
downloaded 411 KB
The downloaded binary packages are in
/var/folders/pl/w9k_0l4d4snfgcv53rp2t_4m0000gn/T//RtmpWScbjK/downloaded_packages
> library(tidyverse)
Error: package or namespace load failed for ‘tidyverse’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘Rcpp’
I even tried to install it on just R and not RStudio too and This is the message that comes up for both tidyverse and caret when I try to install Rcpp both ways on just R and RStudio:
> install.packages("Rcpp")
There is a binary version available but the source version is later:
binary source needs_compilation
Rcpp 1.0.8.2 1.0.8.3 TRUE
Do you want to install from sources the package which needs compilation? (Yes/no/cancel) yes
installing the source package ‘Rcpp’
trying URL 'https://cloud.r-project.org/src/contrib/Rcpp_1.0.8.3.tar.gz'
Content type 'application/x-gzip' length 3086192 bytes (2.9 MB)
==================================================
downloaded 2.9 MB
* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
ERROR: compilation failed for package ‘Rcpp’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp’
The downloaded source packages are in
‘/private/var/folders/pl/w9k_0l4d4snfgcv53rp2t_4m0000gn/T/Rtmp53AysU/downloaded_packages’
Warning message:
In install.packages("Rcpp") :
installation of package ‘Rcpp’ had non-zero exit status
I'm not sure what's going wrong and I'm not seeing any solution on here or other sites that are working for me, I'd appreciate any help with this since I use R alot. If more info is needed please comment, thanks.
It could be that you need to reinstall the rlang package. You can use this code to reinstall this package:
remove.packages("rlang")
install.packages("rlang")
After that you can load the packages tidyverse and caret again:
library(tidyverse)
library(caret)
Check this question for more info: Error: package or namespace load failed for ‘tidyverse’ in loadNamespace

Different version of GlobalOptions package in R

I'm trying to install the package "circlize" and I am having trouble resolving what seems to be a simple error.
When I run:
install.packages("circlize")
It says:
Installing package into ‘*file location*/3.2’
(as ‘lib’ is unspecified)
Warning in install.packages :
dependency ‘GlobalOptions’ is not available
There is a binary version available but the source version is later:
binary source needs_compilation
circlize 0.3.10 0.4.3 FALSE
installing the source package ‘circlize’
trying URL 'https://mirrors.sorengard.com/cran/src/contrib/circlize_0.4.3.tar.gz'
Content type 'application/x-gzip' length 2456906 bytes (2.3 MB)
downloaded 2.3 MB
* installing *source* package 'circlize' ...
** package 'circlize' successfully unpacked and MD5 sums checked
** R
** demo
** inst
** preparing package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
namespace 'GlobalOptions' 0.0.11 is being loaded, but >= 0.0.12 is required
ERROR: lazy loading failed for package 'circlize'
* removing '*file location*/3.2/circlize'
Warning in install.packages :
running command '"*file location*/x64/R" CMD INSTALL -l "*file location*\3.2" *file location*/downloaded_packages/circlize_0.4.3.tar.gz' had status 1
Warning in install.packages :
installation of package ‘circlize’ had non-zero exit status
The downloaded source packages are in
‘*file location*\downloaded_packages’
These parts seem most relevant to me:
dependency ‘GlobalOptions’ is not available
namespace 'GlobalOptions' 0.0.11 is being loaded, but >= 0.0.12 is required
When I run sessionInfo() I see under "other attached packages": [1] GlobalOptions_0.0.11
My best guess is that I have the wrong version of GlobalOptions -- I see that GlobalOptions v0.0.13 is available here, but being new to R, I'm not sure what to do now to get the right version up and running.
I'd really appreciate if someone could tell me where I should look next. (I looked through the documentation within that link, but I'm still lost about what to do now.) Thanks!
If you have R version >=3.3.0 you should
install GlobalOptions_0.0.13 from CRAN
install.packages("GlobalOptions")
quit and restart R
re-install circlize from source as before.
If you have an older R version, update R to a more recent version first.

unable to install packages("caret") completely in R version 3.2.3

> require("caret")
Loading required package: caret
Loading required package: lattice
Loading required package: ggplot2
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘pbkrtest’
So I found that there is lack of "pbkrtest" then I tried to reinstall it.
> install.packages("pbkrtest")
Installing package into ‘C:/Users/ADMIN/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
There is a binary version available but the source version is
later:
binary source needs_compilation
pbkrtest 0.4-2 0.4-3 FALSE
installing the source package ‘pbkrtest’
trying URL 'https://rweb.crmda.ku.edu/cran/src/contrib/pbkrtest_0.4- 3.tar.gz'
Content type 'application/x-gzip' length 164415 bytes (160 KB)
downloaded 160 KB
* installing *source* package 'pbkrtest' ...
** package 'pbkrtest' successfully unpacked and MD5 sums checked
** R
** data
** inst
** preparing package for lazy loading
Warning: replacing previous import by 'stats::sigma' when loading 'pbkrtest'
Error : object 'sigma' is not exported by 'namespace:stats'
ERROR: lazy loading failed for package 'pbkrtest'
* removing 'C:/Users/ADMIN/Documents/R/win-library/3.2/pbkrtest'
The downloaded source packages are in
‘C:\Users\ADMIN\AppData\Local\Temp\Rtmpk7mJT0\downloaded_packages’
Warning messages:
1: running command '"D:/R-3.2.3/bin/x64/R" CMD INSTALL -l
"C:\Users\ADMIN\Documents\R\win-library\3.2"
C:\Users\ADMIN\AppData\Local\Temp\Rtmpk7mJT0/downloaded_packages/pbkrtest_0.4- 3.tar.gz' had status 1
2: In install.packages("pbkrtest") :
installation of package ‘pbkrtest’ had non-zero exit status
It seems like that the installation keeps failing.
As a result, I couldn't use other code using caret packages.
I faced this problem as well on Windows 7. I did following steps in the sequence and it worked.
a) Make sure your R version is updated latest R release 3.2.3
b) The default sources seems to be installing Unix version. So I manually downloaded https://cran.r-project.org/web/packages/pbkrtest/index.html for windows
c) Use manually install function from R menu to install the package.
Cheers,
Ratan
Check version of R by typing version in your console.
If version is not "version.string R version 3.3.2" or later then
Install new version of R from https://cran.r-project.org/bin/windows/base/
Update R version using Tools => Global Options in RStudio.
install package using "install.packages("caret")" in your console.
do require(caret).
test using ?createDataPartition.

Resources