I'm trying to run a script that worked well in the past few days, but has been causing me much grief recently.
When I try to load the caret library, it says that there is a problem with ggplot2. Here is the output:
> library(caret)
Loading required package: lattice
Loading required package: ggplot2
Error: package or namespace load failed for ‘ggplot2’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
object 'pkgInfo' not found
Error: package ‘ggplot2’ could not be loaded
I have no clue what pkgInfo is. Other StackOverflow questions answers to this problem are that that's from not using quotes in your code making R think that it's looking for an object named pkgInfo. But in this case, the error is coming from inside...
...the source code of ggplot2. (maybe, I don't know, it's not my code directly causing the error I know) I've ran install.packages("ggplot", dep = TRUE) and it fixed the problem for now, but I want a longer solution. I'm pretty sure I tried that yesterday and left me to still need to fix it today. I'd also like an explanation if y'all can provide so I can prevent this in the future. Thanks!
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] lattice_0.20-35
loaded via a namespace (and not attached):
[1] compiler_3.5.1 backports_1.1.2 magrittr_1.5 rprojroot_1.3-2 htmltools_0.3.6 tools_3.5.1 yaml_2.2.0
[8] Rcpp_0.12.18 stringi_1.1.7 rmarkdown_1.10 grid_3.5.1 knitr_1.20 stringr_1.3.1 digest_0.6.15
[15] evaluate_0.11
I think it is caret, since caret is wrapper to a lot R package, caret does not use the traditional package dependency process in R, if it did caret would require the install of a lot of packages.
https://cran.r-project.org/web/packages/caret/vignettes/caret.html
You can force it by
install.packages("caret", dependencies = c("Depends", "Suggests"))
The following slide deck (by Max Kuhn, and Zachary Deane-Mayer) explains it a lot better than I could.
https://www.slideshare.net/sermakarevich/odscbos2015maxkhun-150601094910lva1app6892
In the package DESCRIPTION
The Imports section lists packages that may be loaded at run time.
Suggests are packages that may be used but are not required, and Depends are packages that are loaded as soon as caret is loaded
ggplot2 is listed under the Depends section in caret
https://github.com/topepo/caret/blob/master/pkg/caret/DESCRIPTION
I am sorry for posting misleading info, a red herring.
My working directory for R is in my Documents folder. My Documents folder is synced to my google drive, and I noticed a few days ago that google drive was working very hard, sucking up some resources in the background. I saw that a lot of the files it was trying to sync was in the win-library directory for R. I, not knowing how to truly stop the syncing of a subdirectory, deleted the directory from my google drive expecting it to stop messing with my R on my laptop.
Instead, Google started messing with my R files even more. Now that I've stopped syncing my Documents folder with Google Drive, everything is running smoothly.
Related
edit: all screenshots are displayed
I'm teaching stats in Rstudio and we're using the summarytools package. A few of my students are getting different error messages, with the same overall result that the package is not properly installed.
Alex's error seems to download, but not sure if it is installing and the library function cannot find the summarytools package.
Aroun's error is happening mid-install, something about failing to install or load a supporting package 'stringr'.
Zoey's error says something about a non-zero exit status.
While I can run stats in R, I'm a complete newb at troubleshooting package errors. Since I'm not directly experiencing these errors, it is double-difficult to troubleshoot. Any help is appreciated.
Best,
Shawn
It is difficult to judge from these errors, what actually happens. Still, my conjecture is broken or incomplete R installations.
When using R on Windows, please double-check that you installed
1) a single version of R
2) Rtools giving compilers to R
Without Rtools, R will only function in a very limited sense as it cannot compile packages and depends on binary packages that might have been compiled with different versions of R on different platforms.
If these two ideas don't solve the problem and as you are teaching, please think about using a single VM or Docker image (my approach in teaching) such that you and all your students have exactly the same software platform. With this approach, you can use a stable Linux, where R is integrated and well-tested.
Overview
I think - because without each of your student's sessionInfo() output I am only able to make recommendations based off their error messages - the following will help:
Alex: install.packages( pkgs = c("digest", "rapportools") ).
Zoey & Aroun: install.packages( pkgs = "stringr" ).
Afterwards, have all three run install.packages( pkgs = "summarytools" ).
If all else fails, you can have all three run the following commands to install the package from GitHub: install.packages("devtools") followed by devtools::install_github("dcomtois/summarytools").
Methodology
I installed summarytools with the following command install.packages( pkgs = "summarytools" ). All of your students did the same, which led me to print out my session information using sessionInfo():
R version 3.4.3 (2017-11-30)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux
Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] summarytools_0.8.2
loaded via a namespace (and not attached):
[1] Rcpp_0.12.16 matrixStats_0.53.1 codetools_0.2-15 digest_0.6.14 bitops_1.0-6
[6] plyr_1.8.4 magrittr_1.5 stringi_1.1.7 pryr_0.1.4 rapportools_1.0
[11] tools_3.4.3 stringr_1.3.0 pander_0.6.1 RCurl_1.95-4.10 rsconnect_0.8.8
[16] compiler_3.4.3 htmltools_0.3.6
Based on the error messages from each of your students, the installation of summarytools seems to be failing due to dependency packages (i.e. rapportools, digest, and stringr) not downloading with their download of summarytools.
This is an updated answer
For Alex's problem, I suspect the apostrophe in the path ("Alex's PC") might be the culprit.
For Zoey's and Aroun's, it's not clear, maybe some permission issues...?
Possible solutions (for all three cases)
1 - Preferably, try installing through Github:
install.packages('devtools') # if not already installed
library(devtools)
install_github("dcomtois/summarytools")
2 - If solution 1 fails or is not possible for whatever reason, install the latest binaries instead of the most recent (source) version.
install.packages('summarytools', type = 'binary')
3- If all that fails, I'd suggest trying this prior to installation as a last resort. Normally this shouldn't be necessary, but it can't hurt. After completion, try regular install or one of the two previous solutions.
install.packages(c('htmltools', 'matrixStats', 'pander', 'pryr',
'rapportools', 'RCurl', 'Hmisc', 'rstudioapi',
'rmarkdown', 'stringr'))
install.packages('knitr', dependencies = TRUE)
update.packages(ask = FALSE, repos = 'https://cran.rstudio.org')
I want to R CMD check with RStudio my package (for this question I call it pkg). But I get the following error message:
* preparing 'pkg':
* checking DESCRIPTION meta-information ... OK
* installing the package to build vignettes
* creating vignettes ...Error in find_vignette_product(name, by = "weave", dir = docdir, engine = engine) :
Failed to locate the 'weave' output file (by engine 'utils::Sweave') for vignette with name 'my-vignette'. The following files exist in directory 'C:/Users/name/AppData/Local/Temp/RtmpQLnSjE/Rbuild244434d45c05/pkg/vignettes': 'my-vignette.R', 'my-vignette.Rmd'
Execution halted
Error: Command failed (1)
In addition: Warning message:
`cleanup` is deprecated
Execution halted
Exited with status 1.
One first thing, where something might got wrong is that there is no folder called RtmpQLnSjE in my C:/Users/name/AppData/Local/Temp/ directory. Running my Rmd file by hand, does not generate any errors.
I update RStudio to the latest version 1.1.423 and this is my SessionInfo():
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] MCMCglmm_2.25 ape_5.0 coda_0.19-1 lme4_1.1-15 Rcpp_0.12.15 Matrix_1.2-12 hmi_0.9.4
loaded via a namespace (and not attached):
[1] lattice_0.20-35 corpcor_1.6.9 digest_0.6.15 withr_2.1.1 MASS_7.3-48 grid_3.4.3
[7] nlme_3.1-131 cubature_1.3-11 minqa_1.2.4 nloptr_1.0.4 devtools_1.13.4 splines_3.4.3
[13] tools_3.4.3 yaml_2.1.16 parallel_3.4.3 compiler_3.4.3 memoise_1.1.0 tensorA_0.36
Concluding as an answer:
Failed to locate the 'weave' output file
This error can have several root causes and is not always easy to trace down. However, there is a good chance that it is related to code inside the vignette, in particular code navigating directories and such (e.g. setwd() or other functions that may rely on relative paths that could differ between a stand-alone run and the more involved R CMD check)
I recently ran across this when a vignette file had a space in the name (like "My Vignette.Rmd"). It was creating an html file called My-Vignette.html. I think it's the hyphen in the name that was causing issues (based on the answer above along with what I'm seeing.)
I have just enough experience with R to get some things done, but not enough to actually troubleshoot a problem like this. I also would not call myself a programmer, though at some point that would be great. In case it matters, I usually use Rstudio.
I am trying to solve a problem where I have different entries for the same sample (microsatellites with different runs) that I need to condense into one line of information for each sample. I found the perfect package to solve my problem (package = genomatic). The trouble is, that I could not install it for use with the most recent version of R because it was created before version 3.0. So I downloaded version 2.15.3 and am working with the regular bare bones console.
Genomatic was not available through the install packages list, so I downloaded a zip file for Windows from here: http://www2.uaem.mx/r-mirror/web/packages/genomatic/index.html
and then followed the directions from pages 6-7 in the manual (link below) to install it from my own machine.
http://people.oregonstate.edu/~knausb/software/Genomatic_users_manual_v05.pdf
It appeared to install just fine, however when I go to load the library, I get the following error:
> library(genomatic)
Loading required package: tcltk
Loading Tcl/Tk interface ... done
Error in library(genomatic) :
package ‘genomatic’ does not have a NAMESPACE and should be re-installed
I looked through the forum, but could not find an answer for how to fix this. Here is the session info:
> sessionInfo()
R version 2.15.3 (2013-03-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] tcltk stats graphics grDevices utils datasets methods
[8] base
Can somebody help me to make this work?
Thanks!
Liz
EDIT to add: I did try to reinstall, but ended up with the same results.
I'm not sure why you're getting this particular error, as the .zip file provided does appear to have a NAMESPACE file. Installing from source (which shouldn't require any extra installed tools, since the package has only R code, not any compiled [C++/C/FORTRAN] components) seems to help. You can either do this from the official CRAN archives:
library("devtools")
install_version("genomatic",version="0.0.7")
or from the old/frozen repository:
install.packages("genomatic",
repos="http://www2.uaem.mx/r-mirror/", type="source")
(My previous answer was wrong; there is a NAMESPACE file.)
Out of the blue my devtools package will not work. Here is what I get. I have tried numerous fixes on my Windows 8 machine. I have reinstalled Rtools, I have reinstalled devtools but I keep getting the follwoing
require(devtools)
Loading required package: devtools
Error in namespaceExport(ns, exports) :
undefined exports: iteratelist, rowSplit, whisker.escape, whisker.render
Where do I begin?
Winston Chang over on the devtools github said, "Strange, those errors involve the whisker package." So at his behest I am providing some additional information.
> packageVersion('whisker')
[1] ‘0.3.2’
> packageVersion('devtools')
[1] ‘1.3’
> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
I found a solution. I deleted the whisker folder in ~My Documents\R\win-library\3.0\ and reinstalled the package. Everything worked.
Thanks to Winston Chang who made me realize that my devtools problems were coming from the whisker package which I believe devtools relies on. Thank you to #DWin who gave me the idea of chucking out a malfunctioning library and reinstalling the library.
It was when I issued library(whisker) that I realized the problem may not be with devtools at all but rather with whisker
> library(whisker)
Error in namespaceExport(ns, exports) :
undefined exports: iteratelist, rowSplit, whisker.escape, whisker.render
Error: package or namespace load failed for ‘whisker’
I can now load devtools and whisker.
It is odd. I would have thought that my packages would have been reinstalled when I uninstalled R and reinstalled it (one of the desperate steps I took when I was trying to troubleshoot). Evidently ~My Documents\R\win-library\3.0\whisker survived the uninstallation. Clearly I need to learn more about R installation and the ways in which the libraries can be setup.
My guess, in the absence of complete information and a log file for a command line installation, is that you have a corrupt .RData file. The .Rhistory file might alos be a source of corrupted data that results in incomprehensible error messages. (They are invisible to the average R user on both Windows and Mac file browsers.) Windows Explorer let's you choose to show hidden files. In WinXP one of the choices off the "Folder Options" dialog is the "View" panel. Delete first the .Rdata file and if that doesn't work then also delete the .Rhistory file.
My guess was wrong, so if RTools is available then:
install.packages("RGoogleDocs",
repos="http://www.omegahat.org/R", type="source")
I have a rather large chunk of code that breaks sometimes, as far as I can see randomly, with the error message:
This application has requested the Runtime to terminate it in an
unusual way. Please contact the application's support team for more
information.
Some research showed me that this seems to be a Windows/C runtime message when abort is called (see for example this link). This drives me nuts: Since it is not an error thrown by R I have no idea where to look. Does anyone have any clue where R or maybe data.table (if that's possible that a package calls the abort function in C runtime [??]) calls the abort function?
Here are some further information:
The problem is independent from the machine: I tried it on two different machines, it crashed on both of them sometimes.
The problem is independent on the R version: I tried it with 2.13.1, 2.13.2, and 2.14.0.
Both machines run Windows 7 (64 bit).
The problem seems to be related to the size of my data.tables. When I artificially reduce the size of the bigger data.table, the code runs like a charm. Interestingly, however, one machine has far more RAM than the other (16 GB compared to 6 GB). This additional RAM, however, doesn't really help, at least it seems so.
The problem is not reproducible and breaks at different sections in my code. I noticed this because my code is run in a Sweave document, so I can open the .tex file after R has crashed and it always stops at a different position. However, it always seems to be when a data.table operation is called (that doesn't mean a lot though because my code relies heavily on data.table). However, even when I don't call Sweave, but just run the code, it breaks sometimes as well. So it does not seem to be related to Sweave.
It has nothing to do with the editor I'm using. I use RStudio, but reproduced this behavior by running the code in a plain R command window.
That's basically all possible explanations I've come up with. So it would be great if anyone has any hints on where this error could come from or what else I could check.
PS: I won't be at my machine the next couple of days, so I hope you forgive me when I don't give feedback immediately. Nevertheless, I wanted to post this question before Xmas, otherwise I couldn't enjoy it with my beloved R suffering and I'm sitting at home, not trying to cure it...
UPDATE
I looked further into the issue and after a while, I got a rather minimal example with data.table that breaks my R session. If this issue is fixed and it solves the crash of R as described here (note that this is a big if because the example I posted on the data.table list just breaks my R session and does not end it with the error message I described here), I will write an answer here and accept it.
Suddenly, same error came up from rvest package in the lines:
raw_HTML %>% html_nodes(xpath=HTML_table_xpath)
Switching to R 3.3.1 64bit fixed the problem (which remains with 32 bit R for now). That may be a workaround for some. In my case, rJava package requires 32 bit R :(
In case it helps anyone:
> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] rvest_0.3.2 xml2_1.0.0 xts_0.9-7 zoo_1.7-13 doParallel_1.0.10 iterators_1.0.8
[7] foreach_1.4.3 plyr_1.8.4 jsonlite_0.9.22 futile.logger_1.4.1
loaded via a namespace (and not attached):
[1] Rcpp_0.12.5 lattice_0.20-33 codetools_0.2-14 XML_3.98-1.4 R6_2.1.2 grid_3.3.1
[7] futile.options_1.0.0 magrittr_1.5 mail_1.0 httr_1.2.0 stringi_1.1.1 curl_0.9.7
[13] lambda.r_1.1.7 tools_3.3.1 stringr_1.0.0 selectr_0.2-3
OK, this was basically a hard to detect issue with data.table that should be fixed with the version 1.7.8. For more information, see the NEWS file.