Unable to load packages after updating Rstudio - r

I recently updated Rstudio to the latest version, but am now getting continuous error messages when I attempt to use install.packages and library().
Below is an example of what I'm seeing:
> install.packages("tidyverse", type="binary") ## Basic data manipulation
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/
trying URL 'http://cran.rstudio.com/bin/windows/contrib/4.2/tidyverse_1.3.2.zip'
Content type 'application/zip' length 428925 bytes (418 KB)
downloaded 418 KB
package ‘tidyverse’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\King Awesome\AppData\Local\Temp\RtmpaU0srW\downloaded_packages
> library(tidyverse)
Error: package or namespace load failed for ‘tidyverse’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
namespace ‘cli’ 3.3.0 is already loaded, but >= 3.4.0 is required
In addition: Warning message:
package ‘tidyverse’ was built under R version 4.2.2
I'm pretty certain the issue has to do with my current working directory and library paths not matching, but I do not want to start making major changes without the advice of more experienced R users for fear of making the situation more complex.
> getwd()
[1] "C:/Users/King Awesome/Documents/Cyclistic Raw Data/Cyclistic Slice/Cyclistic Final 10 13/Cyclistic Final PT 10 13"
> .libPaths()
[1] "T:/Gaem/R-4.2.1/library"

It looks like the solution was a full wipe. I removed all installed packages, reinstalled and now have functionality again. Good solution, #PavoDive

Related

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

Problem in calling the function panelvar from the library after being installed

I was working with the panelvar package, that I have installed today.I created a new R script, and ran library(panelvar) and got the following error:
library(panelvar)
Error: package or namespace load failed for ‘panelvar’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘hms’
In fact, I had already installed the package:
install.packages("panelvar")
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/
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/panelvar_0.5.2.zip'
Content type 'application/zip' length 2565900 bytes (2.4 MB)
downloaded 2.4 MB
package ‘panelvar’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\JSamridhi\AppData\Local\Temp\Rtmp0GEDNw\downloaded_packages
When I try uploading the package, I get the same error again. I tried deleting the file from the library using .libpath and reinstalled the whole thing but its just not working.

Is it possible to use package semPlot with R 3.6.2?

I upgraded R to version 3.6.2 and have discovered that package semPlot will not work. It installs without any problems, but when I try to load it I get the message,
Error: package or namespace load failed for ‘semPlot’ in
loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck =
vI[[j]]): there is no package called ‘ggm’
I then tried to install ggm but get the following warning and error:
Warning in install.packages : dependency ‘graph’ is not available
There is a binary version available but the source version is
later:
binary source needs_compilation ggm 2.3 2.5 FALSE installing the source package ‘ggm’ trying URL
'https://cran.rstudio.com/src/contrib/ggm_2.5.tar.gz' Content type
'application/x-gzip' length 109414 bytes (106 KB) downloaded 106 KB
ERROR: dependency ‘graph’ is not available for package ‘ggm’ removing
‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/ggm’
Warning in install.packages : installation of package ‘ggm’ had
non-zero exit status"
I then tried to install graph, but it says:
package ‘graph’ is not available (for R version 3.6.2).
I wondered if anyone else had experienced this problem, and had any solutions so I can load semPlot with R 3.6.2?
Many thanks.
I also have R 3.6.2 and get all errors you get. But when I try to install the semPlot package from GitHub, it works fine, as follows:
install.packages('devtools')
library(devtools)
install_github('SachaEpskamp/semPlot', dependencies = T)
library(semPlot)
Please not that I tried the cran/semPlot repository but didn't work for me, whereas SachaEpskamp/semPlot does.
Hope you get it working.

Cannot remove prior installation of package, but package not found

I have been installing packages into R since the day I downloaded it. Version 3.4.1. Today it gave me an issue when I tried to install a new package, SLOPE that had me update and reboot R. I said okay. However, in doing so I then went to call packages using the library and it told me:
> Error: package or namespace load failed for ‘plyr’ in loadNamespace(j
> <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]): there
> is no package called ‘Rcpp’
I have clicked around on here and it looks like I need to download and install the Rccp package. I tried that and got this answer:
install.packages("Rcpp") Installing package into ‘\tgdcfs01/Users/jsmith/Documents/R/win-library/3.4’ (as ‘lib’ is
unspecified) trying URL
'https://mran.microsoft.com/snapshot/2017-09-01/bin/windows/contrib/3.4/Rcpp_0.12.12.zip'
Content type 'application/zip' length 3319164 bytes (3.2 MB)
downloaded 3.2 MB
package ‘Rcpp’ successfully unpacked and MD5 sums checked Warning in
install.packages : cannot remove prior installation of package
‘Rcpp’
The downloaded binary packages are in
C:\Users\jsmith\AppData\Local\Temp\RtmpYHBW2f\downloaded_packages
So then I tried uninstalling Rccp and got this message:
remove.packages(Rcpp)
Error in remove.packages : object 'Rcpp' not found
What am I missing?
In order to fix it, I in fact did not update R in the first place. I needed to do the following:
install.packages("installr")
library(installr)
updateR()
Then I updated R, but I did not use the recommended setting of using R Gui. Then I was able to re-install packages and go from there.

Error installing PARTY package in R

Newbie R user here.
I wanted to install the party package in RStudio (Ver 0.98.507), but whether I install it directly from the CRAN repository or whether I save the file first and then load it in R, I get the following error message:
> install.packages("party")
Installing package into ‘C:/Users/Linda/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.1/party_1.0-15.zip'
Content type 'application/zip' length 731049 bytes (713 Kb)
opened URL
downloaded 713 Kb
package ‘party’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\Linda\AppData\Local\Temp\~~~~~~~\downloaded_packages
> library("party", lib.loc="C:/Users/Linda/Documents/R/win-library/3.1")
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
object 'vI' not found
Error: package or namespace load failed for ‘party’
I am unable to interpret the error message.
Every other package download and installation has worked so far though (caret, tree, rpart) so I am confused why this is not working.
Install "multcomp", then "party"
install.packages("multcomp")
library(multcomp)
install.packages("party")
library(party)
I was using ctree. and then I wanted to change the font size of the tree chart. I installed package "partykit". Then ctree doesn't work anymore. I was spending LONG time try to debug.. Later I found out there is also a ctree in the "partykit". In order to run ctree using "party" we would need to uninstall "partykit" so that there is no conflict..
(might not be exactly what the question is trying to solve. but hope this would be a reference to others :-))

Resources