Errors Installing and Calling R Packages - r

I recently got a new work computer where they reinstalled RStudio on it. The RStudio version was the same as the one I had on my previous computer which worked perfectly.
On my previous computer I would install and call the packages from a local folder by simply typing this code .libPaths("C:/R/Lib"). This worked perfectly for me, but now with my new computer I get an error whenever I try to call these libraries. The error message I'm getting is:
> .libPaths("C:/R/Lib")
>
Error in rbind(info, getNamespaceInfo(env, "S3methods")) :
number of columns of matrices must match (see arg 2)
In addition: Warning messages:
1: In readLines(file, skipNul = TRUE) :
cannot open compressed file 'C:/R/Lib/abd/DESCRIPTION', probable reason 'No such file or directory'
2: In readLines(file, skipNul = TRUE) :
cannot open compressed file 'C:/R/Lib/acepack/DESCRIPTION', probable reason 'No such file or directory'
> library(kableExtra)
Error: package or namespace load failed for ‘kableExtra’ in rbind(info, getNamespaceInfo(env, "S3methods")):
number of columns of matrices must match (see arg 2)
In addition: Warning message:
package ‘kableExtra’ was built under R version 3.6.3
Any suggestions on how to solve this issue is greatly appreciatted!

Related

R Studio gzfile error when using library() function

I am getting an error when trying to utilize any installed packages.
Here is the code I use.
install.packages("tidyverse")
> library(tidyverse)
Error in gzfile(file, "rb") : cannot open the connection
In addition: Warning message:
In gzfile(file, "rb") :
cannot open compressed file 'C:/Users/M/Appdata/Local/R/win-library/4.2/vctrs/R/vctrs.rdx', probable reason 'No such file or directory'
Error: package or namespace load failed for ‘tidyverse’:
unable to load R code in package ‘vctrs’
I have tried the following:
restarting R Studio
re-installing R Studio
downloading the packages and putting them in wd()
tried moving the wd()
appreciate the help

Unable to load dplyr in R

I recently upgraded to R 3.5.0 (Windows 10). Following this I have been unable to install dplyr. The error message I get is:
Error in read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) :
cannot open the connection
In addition: Warning messages:
1: In download.file(url, destfile, method, mode = "wb", ...) :
downloaded length 17723392 != reported length 17880019
2: In unzip(zipname, exdir = dest) :
error 1 in extracting from zip file
3: In read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")):
cannot open compressed file 'BH/DESCRIPTION', probable reason 'No such file or directory'
I have been able to install other packages and changing the mirror has not helped. I have seen others report this error on but not a consistent fix.
try
install.packages('tidyverse')
then
library(tidyverse)
Tidyverse is a package that includes dplyr and it usally has less problem to get installed.
It also contains ggplot2 so you might not need to load it anymore once you call tydyverse
Have you tried setting dependencies = TRUE, like
install.packages("foo", dependencies=TRUE)
On several occasions this has helped me install packages, that wouldn't get installed otherwise.

Can't install twitteR package in R

I'm trying to install the mentioned package, but in the middle of the process the following message shown and the installation fails.
package ‘rjson’ successfully unpacked and MD5 sums checked
Error in read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) :
cannot open the connection
In addition: Warning messages:
1: In download.file(url, destfile, method, mode = "wb", ...) :
downloaded length 745472 != reported length 769130
2: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file
3: In read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) :
cannot open compressed file 'DBI/DESCRIPTION', probable reason 'No such file or directory'
The solution provided here couldn't help, by the way!
You have not shown us "HOW" you tried installing pkg-twitteR but from the fact that it tried to install an additional package, I'm guessing you used dependencies=TRUE in the install.packages-command. (I pretty much always use that parameter, so i'm not criticizing that strategy.) In any case you should now (and always) edit your question to include the exact command or actions you used. You should also include details of your OS and R versions. The missing item appears to be in the "DBI"-package, so I would try:
install.packages("DBI", dependencies=TRUE)
And then retry to install. The installation process sometimes fails when dependencies of dependencies are not met.

R "Userfriendlyscience" Package

I am having trouble loading the userfriendlyscience package in R. I am able to load other packages without a problem but this one is giving me the error:
Warning in install.packages : error 1 in extracting from zip file
Warning in install.packages : cannot open compressed file
'BH/DESCRIPTION', probable reason 'No such file or directory' Error in
install.packages : cannot open the connection
Not sure how to resolve the issue.

ggplotly won't work or re-install - is there a way to deinstall it?

I am having a problem I think I may be able to solve my if I could deinstall 'ggplotly' before attempting to reinstall it.
Here's what happened:
Code that worked fine when an instructor demoed it, failed when I tried it at home. It was R Markdown. Investigating the problem code cell line by line, the problem was centered around ggplot2 (which uses ggplotly). Code and error messages are provided below. In the code "graph" was a ggplot2 facet_wrap() that was supposed to pass into ggplotly.
Here is the excerpt from my console of the problem and a failed attempt to fix it by re-installing:
> ggplotly(graph)
Error in dev_fun(tmpPlotFile, width = deviceWidth, height = deviceHeight) :
unable to start png() device
> ggplotly(graph)
Error in RStudioGD() :
Shadow graphics device error: r error 4 (R code execution error)
In addition: Warning messages:
1: In grDevices:::png("C:/Users/User/AppData/Local/Temp/Rtmp0ar20f/3b613ba7d0ce4228bc937aee7cfcb112.png", :
unable to open file 'C:/Users/User/AppData/Local/Temp/Rtmp0ar20f/3b613ba7d0ce4228bc937aee7cfcb112.png' for writing
2: In grDevices:::png("C:/Users/User/AppData/Local/Temp/Rtmp0ar20f/3b613ba7d0ce4228bc937aee7cfcb112.png", :
opening device failed
> install.packages("plotly")
Error in install.packages : Updating loaded packages
Error in gzfile(file, mode) : cannot open the connection
In addition: Warning message:
In gzfile(file, mode) :
cannot open compressed file 'C:\Users\User\AppData\Local\Temp\Rtmp0ar20f/libloc_190_4464fd2b.rds', probable reason 'No such file or directory
As per comments on this thread, a package can be de-installed with remove.packages. As per the original problem on this post, de-installing and re-installing cleared it, but for completeness, here are all the precautions I took to improve the chances of this working:
removed the package as indicated
re-initialized RStudio (exited without saving the workspace and re-entered it)
By default, it remembered some of my environment so I clicked the broom icon to clear out all variables and data from memory
re-installed the package
re-loaded the original R file and tested to make sure all worked as expected.
This is what I saw in the console with de-installing and re-installing in contrast to the messages shown on the original post:
During de-installation:
> remove.packages("plotly")
Removing package from ‘C:/ProgramFilesCoders/R/R-3.3.2/library’
(as ‘lib’ is unspecified)
Error in gzfile(file, mode) : cannot open the connection
In addition: Warning message:
In gzfile(file, mode) :
cannot open compressed file 'C:\Users\User\AppData\Local\Temp\Rtmp0ar20f/libloc_190_4464fd2b.rds', probable reason 'No such file or directory'
During re-installation:
> install.packages("plotly")
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/plotly_4.5.6.zip'
Content type 'application/zip' length 817502 bytes (798 KB)
downloaded 798 KB
package ‘plotly’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\User\AppData\Local\Temp\RtmpGco6OK\downloaded_packages

Resources