Issue loading 'dplyr' sometimes - r

Sometimes when I try to load dplyr I get the following error:
Error in library.dynam(lib, package, package.lib) :
shared object ‘dplyr.so’ not found
In addition: Warning message:
S3 methods ‘[.grouped_df’, ‘[.tbl_df’, ‘all.equal.tbl_df’, ‘all.equal.tbl_dt’, ‘anti_join.data.frame’, ‘anti_join.data.table’, ‘anti_join.tbl_df’, ‘anti_join.tbl_sql’, ‘arrange_.data.frame’, ‘arrange_.data.table’, ‘arrange_.grouped_dt’, ‘arrange_.tbl_df’, ‘arrange_.tbl_dt’, ‘arrange_.tbl_sql’, ‘as.data.frame.grouped_df’, ‘as.data.frame.rowwise_df’, ‘as.data.frame.tbl_cube’, ‘as.data.frame.tbl_df’, ‘as.data.frame.tbl_dt’, ‘as.data.frame.tbl_sql’, ‘as.fun_list.character’, ‘as.fun_list.fun_list’, ‘as.tbl.data.frame’, ‘as.tbl.data.table’, ‘as.tbl.tbl’, ‘as.tbl_cube.array’, ‘as.tbl_cube.data.frame’, ‘as.tbl_cube.matrix’, ‘as.tbl_cube.table’, ‘auto_copy.tbl_cube’, ‘auto_copy.tbl_df’, ‘auto_copy.tbl_dt’, ‘auto_copy.tbl_sql’, ‘c.sql’, ‘collapse.data.frame’, ‘collapse.tbl_df’, ‘collapse.tbl_dt’, ‘collapse.tbl_sql’, ‘collect.data.frame’, ‘c [... truncated]
Error: package or namespace load failed for ‘dplyr’
Once I restart the R process is will work fine. Is there any reason this is happening sometimes but not other times?

I can't comment because I don't have 50 reputation HOWEVER I did have the same problem and I followed what marbles had suggested.
I am using a Mac and was using Microsoft's checkpoint package and could not load it properly if I had library(dplyr) in my R chunk. I removed the dplyr folder from ~/Library/R/3.3/library/dplyr as well as the dplyr folder from ~/.checkpoint/2017-01-01/lib/dplyr then just loaded the libraries and checkpoint seemed to correctly load dplyr.
I was obviously using the checkpoint date of January 1 2017. I also had to create the local .checkpoint folder because it was not automatically created. My document compiles (I haven't tried any serious code in it yet though) so I am assuming it works.

Related

How can I install and use (mice) function in R?

I want to use mice function to handle the missing data that I have in (data). I installed the package and I called the library. However, when I am trying to apply the function to my data it gives me error as below:
(Error in mice(data[, 5:9], m = 3, seed = 123) :
could not find function "mice")
I have a normal data frame that includes NAs
install.packages('mice')
library(mice)
library(VIM)
md.pattern(data)
md.pairs(data)
My_New_Data <- mice(data[,5:9], m=3, seed=123)
I am expecting the function to solve the problem and replace the NAs with reasonable values. It did not work at all!
Edit (incorporating comment suggestion)
In the comments the running mice::mice(data[, 5:9], m = 3, seed = 123). I ran this and the following error was returned.
Error in get(Info[i, 1], envir = env):
lazy-load database 'C:/Users/MUSTAFA KAMAL/Documents/R/win-library/3.5/broom/R/broom.rdb' is corrupt
In addition:
Warning message: In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
In order to incorporate an answer to this question, I will rewrite my comment which resolved the problem, in the form of a short answer.
From the comments executing mice::mice(data[, 5:9], m = 3, seed = 123) resulted in an error message, showing the directory ~/Documents/R/win-library/**3.5**/broom/R/broom.rdb being corrupt.
From the corrupted directory path, one can see that OP was running R-3.5.x, while the newest version is R-3.6.x. Some packages updated since the most recent R-update has experienced similar problems, as such a first step towards solving these types of issues is updating R. The installr contains the function updateR which can help smooth over such updates, while also updating any outdated packages.
As a side note, an update sometimes fails to update the actual packages or results in other packages being corrupted, as such if an error persists one solution is to simply delete and re-install the package (or the entire ~/Documents/R/win-library/3.z/ directory). In the question from OP the corrupt package is the broom package, as such one could re-install this package by running
remove.packages("broom")
install.packages("broom")
which should resolve any leftover issues. Note however multiple packages might be corrupt, and likely only one will be shown every time the function is executed. In such cases a full package clear will do the trick, but requires re-installing all packages. For this one can export all installed packages prior to removing them all, by noting that a full list of installed packages is contained in installed.packages(), which can then be exported to a file with for example write.table or write.csv.

Error: 'MonetDBLite' is not an exported object from 'namespace:MonetDBLite'

Working through a download script for CPS data found here. Using the script verbatim, per recent update, except for the Java modification that I added for my environment (below) to fix a previous error in loadnamespace. While I am familiar with the basics of R, this is my first foray into MonetDBLite.
# configure Java
if (Sys.getenv("JAVA_HOME")!="")
Sys.setenv(JAVA_HOME="")
library(rJava)
Now I am getting the following error, which generally comes after 380,000 of the 400,000 cps asec lines are processed.
Warning message:
In readLines(url) :
incomplete final line found on 'http://thedataweb.rm.census.gov/pub/cps/march/asec2015early_pubuse.dd.txt'
Error in dbConnect(MonetDBLite::MonetDBLite(), dbfolder) :
error in evaluating the argument 'drv' in selecting a method for function 'dbConnect': Error: 'MonetDBLite' is not an exported object from 'namespace:MonetDBLite'
MonetDBLite has just been updated on CRAN, please reinstall.

R - Error in arules and arulesViz packages

I am using the arules and arulesViz package in R to implement a set of association rules on my data. It worked fine till few days back. But now I am getting the below error whenever I load the R file where I used this package.
Loading required package: arules
Loading required package: Matrix
Attaching package: ‘arules’
The following objects are masked from ‘package:base’:
%in%, write
Error in length(obj) : Method length not implemented for class rules
In addition: Warning message:
package ‘arules’ was built under R version 3.1.3
Error in length(obj) : Method length not implemented for class rules
Error in length(obj) : Method length not implemented for class rules
Error in length(obj) : Method length not implemented for class rules
If I use the plot() function from arulesViz I face this below error:
Error in seq_along(x) : Method length not implemented for class rules
So tried to uninstall the package and reinstalled it. It worked only for the first time after reinstallation, it also threw the below error when I used for the first time after reinstallation.
Loading required package: arules
Loading required package: Matrix
Attaching package: ‘arules’
The following objects are masked from ‘package:base’:
%in%, write
But once I saved the file and loaded it back the old error messages repeated again. I searched in Google but nothing close to this type of error is ever posted by anyone. Your help is appreciated. Thanks.
FWIW I got this same error and this SO page is the only Google result that comes up. This fixed it for me (but I don't know why...)
> detach("package:arules", unload=TRUE)
> library("arules", lib.loc="[wherever your R libraries go]")

Problems building an R package (NAs introduced by coercion)

I have written the Boggler package which includes a Play.Boggle() function that calls, on line 87, a progress bar script using shell:
shell(cmd = sprintf('Rscript.exe R/progress_bar.R "%i"', time.limit + 1), wait=FALSE)
Everything works fine when sourcing the files individually and then calling the main Play.Boggle() function, but when I try to check/build the package (under Win7-64 using RStudio), I get a failure message -- here's what the 00install.out reports:
** preparing package for lazy loading
Warning in eval(expr, envir, enclos) : NAs introduced by coercion
Error in time.limit:0 : NA/NaN argument
To make sure the argument "%i" (time.limit + 1) was correctly passed to the progress_bar.R, I added a cat(time.limit) to the script (commenting the rest out to make sure the package would build without any errors) and directed its output to a log file like this:
'Rscript.exe R/progress_bar.R "%i" > out.log'
Conclusion: the time limit is indeed passed along as expected. So I can't figure out why I get this "NA/NaN argument" error message. It must have something to do with lazy loading, concept that I haven't fully got my head around yet.
So my question is: what can I do to successfully check/build this package with full functionality (including progress_bar.R)?
Note: On github, the progress_bar.R script is there but all its content is commented out so that the package can successfully be installed. The shell(...) function call is still active, doing nothing but executing an empty script.
So the problem arises when trying to build or check, in which case all R scripts are executed, as pointed out by Roland. A simple workaround allows the package to check/build without any problems. The fix is just to add to the progress_bar.R the following lines after it tries to recuperate the commandargs (lines 10-11):
if(time.limit %in% c(NA, NaN))
time.limit <- 10 # or any minimal number
There's surely other ways to go about this. But this being a game programmed for fun, I'll happily go with that patch. Hopefully this can be of help to someone down the road and I won't have wasted 50 precious rep points in vain for that bounty! :D

dependent packages not loading in R on Debian

I'm having trouble loading the sde package on a clean Debian install running R 2.11.1. I've seen this behavior with some other packages, however, so I don't think it's specific to only this one package. Here's an example of the conundrum:
>install.packages("sde", lib.loc=libPath)
... installs sde, and the packages it's dependent on: zoo, fda
> library(sde, lib=libPath)
Loading required package: fda
Error: package 'fda' could not be loaded
In addition: Warning message:
In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) :
there is no package called 'fda'
ok, that's odd. I saw fda being installed. So I manually load the dependencies:
> library(zoo, lib=libPath)
> library(fda, lib=libPath)
Loading required package: splines
ok, that worked. Now let's try sde:
> library(sde, lib=libPath)
To check the errata corrige of the book, type vignette("sde.errata")
WTF? it loaded fine?!?
So why can I manually load the packages but R is not picking them up automagically?
Adding to my confusion, I discovered during debugging that if I don't use the lib=libPath then everything works just fine. So it looks like the use of a custom path for packages is screwing this all up... but why?
You confirmed my suspicions in the comments. You need to do one of two things:
.libPaths(libPath)
or
library(sde, lib=c(libPath,.libPaths()))
I prefer the first method because the second requires you do that for all calls to library.

Resources