How to troubleshoot devtools unwanted side effects - r

I have run into very weird side effects when using devtools functions. Here is a simple example.
Basically, I start a clean R session, create an empty package and then use load_all to load the new package. Once I have done that, the help function doesnt work anymore. Here is screen capture:
R version 3.1.0 (2014-04-10) -- "Spring Dance"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: i386-w64-mingw32/i386 (32-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> setwd("c:/Scratch")
> require(devtools)
Loading required package: devtools
Attaching package: ‘devtools’
The following objects are masked from ‘package:utils’:
?, help
The following object is masked from ‘package:base’:
system.file
> help("data.frame")
starting httpd help server ... done
> create("mypackage",rstudio=F)
Creating package mypackage in .
No DESCRIPTION found. Creating with values:
Package: mypackage
Title: What the package does (short line)
Version: 0.1
Authors#R: "First Last <first.last#example.com> [aut, cre]"
Description: What the package does (paragraph)
Depends: R (>= 3.1.0)
License: What license is it under?
LazyData: true
> help("data.frame")
> load_all("mypackage")
Loading mypackage
> help("data.frame")
Error in names(t1) <- rep(names(L), lapply(L, length)) :
attempt to set an attribute on NULL
>
Here is the session info:
> sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: i386-w64-mingw32/i386 (32-bit)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] mypackage_0.1 devtools_1.5
loaded via a namespace (and not attached):
[1] digest_0.6.4 evaluate_0.5.5 httr_0.3 memoise_0.2.1 parallel_3.1.0 RCurl_1.95-4.1 stringr_0.6.2 tools_3.1.0 whisker_0.3-2
>
The help command not working is just an example, there are some really other strange stuff I noticed. Like data.table subsetting function not working anymore. I would appreciate if you could give me some pointers how you to attack the problem.

This is a bug in devtools 1.5 which happens when a project has no help files. I just pushed a fix.
On non-Windows platforms, you can update to the latest version with devtools::install_github('hadley/devtools'). On Windows, see ?build_github_devtools for instructions on how to update.

Related

R encountered a fatal error! How can I fix it?

My RStudio says "R encountered a fatal error.: Unexpected exception: basic_stringThe session was terminated".
I checked major information sources like stackoverflow, reddit,R community, but I'm still unable to figure this out. Thank you so much your time in advance!
MacOS: 13.1
R Studio: Version 2022.12.0+353 (2022.12.0+353)Version 2022.12.0+353 (2022.12.0+353)
Error messages R shows
"R encountered a fatal error.: Unexpected exception: basic_stringThe session was terminated"
"R encountered a fatal error.The session was terminated."
"null"
I uninstalled R and RStudio multiple times and reinstalled again but they all showed the same error messages.
Also, I installed an older version of RStudio but it didn't work either.
This is the hardest challenge that I've ever faced in my data journey.
R version 4.2.2 (2022-10-31) -- "Innocent and Trusting"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
[Previously saved workspace restored]
> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur ... 10.16
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
LAPACK:/Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.2.2

How to deal with: Error: could not find function "read_csv"

I installed the package readr and tried to upload a .csv file in Rstudio.
When I try to load this package I get the following error:
> library(readr)
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()),
versionCheck = vI[[j]]) : there is no package called ‘hms’ In addition:
Warning message: Paket ‘readr’ wurde unter R Version 3.2.5 erstellt
Error: Laden von Paket oder Namensraum für ‘readr’ fehlgeschlagen
When I try to upload the .csv file in R I get the error:
> dataX<-read_csv("file.csv")
Error: could not find function "read_csv"
The result of sessionInfo() is:
> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] colorspace_1.3-2 scales_0.4.1 R6_2.2.2 lazyeval_0.2.0 plyr_1.8.4
[6] tools_3.2.2 gtable_0.2.0 tibble_1.3.0 Rcpp_0.12.10 ggplot2_2.2.1
[11] grid_3.2.2 munsell_0.4.3
I will appreciate your help. Thanks.
Ok, I was able to duplicate the problem on Windows. How and Why?
Resolution - Install R3.4.4
How
Install R3.4.4
Install Rtools3.4.
Launch R
> install.packages("readr")
Why?
The issue here (appears to be) that readr and the TidyVerse packages require later versions of R than R3.2.2. and the WIndows Rtools you have. I was able to duplicate the issue described by installing R3.2.2 and RTools3.2 and then trying to instal readr.
I did not encounter the error on installation of R3.4.4.
Background on Upgrading R on Windows:
You can install multiple versions of R (Base environment) and R Tools (Development environment) on Windows. My personal recommendation is to uninstall R, install the new versions of R, then install the latest R Tools and copy over the libraries per Windows faq below.
R Windows FAQ
2.8 What’s the best way to upgrade?
That’s a matter of taste. For most people the best thing to do is to uninstall R (see the previous Q), install the new version, copy any installed packages to the library folder in the new installation, run update.packages(checkBuilt=TRUE, ask=FALSE) in the new R and then delete anything left of the old installation. Different versions of R are quite deliberately installed in parallel folders so you can keep old versions around if you wish.
For those with a personal library (folder R\win-library\x.y of your home directory, R\win64-library\x.y on 64-bit builds), you will need to update that too when the minor version of R changes (e.g. from 3.0.2 to 3.1.0). A simple way to do so is to copy (say) R\win-library\3.0 to R\win-library\3.1 before running update.packages(checkBuilt=TRUE, ask=FALSE).
I too had the similar problem and re-installing package "tidyverse" did the trick for me while I was already on 3.4.4 version of R.
For me, it was loading tidyverse into the environment that did the trick. Load both tidyverse and dplyr

R Package Doesn't Install in Jupyter Notebook, But Installs in RStudio and R app

I'm trying to install the package PerformanceAnalytics using the following code in a Jupyter Notebook, which I've used to install many packages successfully, such as ggplot2, with the following code:
install.packages("PerformanceAnalytics", repos='http://cran.r-project.org')
But I read on many other questions that adding dependencies=TRUE would solve the issue. Unfortunately, it did not. I keep getting the following error message.
install.packages("PerformanceAnalytics", repos='http://cran.r-project.org',
dependencies=TRUE)
Warning message in install.packages("PerformanceAnalytics", repos =
"http://cran.r-project.org"): “installation of package ‘PerformanceAnalytics’
had non-zero exit status”Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
The package installs without a problem in the R app and RStudio. Is there something I'm missing that Jupyter requires for this specific package? I'm using macOS 10.12.5. Below is the info when I run sessionInfo().
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin11.4.2 (64-bit)
Running under: macOS Sierra 10.12.5
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] R6_2.2.0 magrittr_1.5 IRdisplay_0.4.4 pbdZMQ_0.2-4
[5] tools_3.3.2 crayon_1.3.2 uuid_0.1-2 stringi_1.1.2
[9] IRkernel_0.7.1 jsonlite_1.1 stringr_1.1.0 digest_0.6.10
[13] repr_0.10 evaluate_0.10
The solution from the question at Is it possible to install bioconductor package 'rain' in R Jupyter notebook? solved my issue as well. I was using Anaconda's version of R. I uninstalled Anaconda and instead installed Jupyter Notebook and IRkernal manually which resolved my issue. See the answer from the above link for full details.

tcltk not loading and causes R-gui to become unresponsive or crash

I've run into a problem with getting tcltk to run properly on r-gui. It's a required package for one of the packages (aplpack) I'd like to work with.
Preliminary Stuff
13" Macbook Air
OSX Yosemite - Version 10.10.5
R Version 3.2.3
R.app GUI 1.66 (6956) x86_64-apple-darwin14.5.0
r and r-gui were installed via homebrew
I installed aplpack in order to use the bagplot function. Upon loading the package I received the following output:
Loading required package: tcltk 2015-12-23 09:44:11.134 R[6529:31353]
-[NSApplication _setup:]: unrecognized selector sent to instance 0x60800011b3f0 2015-12-23 09:44:11.135 R[6529:31353] ***
run_REngineRmainloop: exception -[NSApplication _setup:]: unrecognized
selector sent to instance 0x60800011b3f0 caught during REPL iteration.
Update to the latest GUI version and consider reporting this properly
(see FAQ) if it persists and is not known. Consider saving your work
soon in case this develops into a problem.
The session became unresponsive and I had to force quit.
To try and solve the problem, I checked to see if tcltk was installed:
> capabilities()["tcltk"]
tcltk
TRUE
It was also available via the package manager but trying to load it, both through the gui and using library("tcltk") caused R to become unresponsive and resulted in an identical error:
2015-12-23 09:49:24.370 R[6571:33844] -[NSApplication _setup:]:
unrecognized selector sent to instance 0x608000108f70 2015-12-23
09:49:24.370 R[6571:33844] *** run_REngineRmainloop: exception
-[NSApplication _setup:]: unrecognized selector sent to instance 0x608000108f70 caught during REPL iteration. Update to the latest GUI
version and consider reporting this properly (see FAQ) if it persists
and is not known. Consider saving your work soon in case this develops
into a problem.
Some googling led me to do the following:
uninstall r-gui via homebrew
uninstall r via homebrew
download and install the most recent version of xquartz
installed homebrew/dupes/tcl-tk (which I thought was supposed to fix the issue)
ran brew update
ran brew upgrade
ran brew doctor
installed r via homebrew
installed r-gui via homebrew
After taking the above steps, I'm still running into the same issue as before.
Here is the output of sessionInfo():
sessionInfo() R version 3.2.3 (2015-12-10) Platform: x86_64-apple-darwin14.5.0 (64-bit) Running under: OS X 10.10.5
(Yosemite)
locale: [1]
en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages: [1] stats graphics grDevices utils
datasets methods base
Following the advice in the Mac OSX FAQ (to attempt to replicate the issue), I opened the r in terminal and was able to not only load tcltk, but also aplpack:
R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree" Copyright (C)
2015 The R Foundation for Statistical Computing Platform:
x86_64-apple-darwin14.5.0 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY. You are
welcome to redistribute it under certain conditions. Type 'license()'
or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors. Type
'contributors()' for more information and 'citation()' on how to cite
R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help. Type 'q()' to
quit R.
sessionInfo() R version 3.2.3 (2015-12-10) Platform: x86_64-apple-darwin14.5.0 (64-bit) Running under: OS X 10.10.5
(Yosemite)
locale: [1]
en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages: [1] stats graphics grDevices utils
datasets methods base
library("aplpack") Loading required package: tcltk
sessionInfo() R version 3.2.3 (2015-12-10) Platform: x86_64-apple-darwin14.5.0 (64-bit) Running under: OS X 10.10.5
(Yosemite)
locale: [1]
en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages: [1] tcltk stats graphics grDevices
utils datasets methods [8] base
other attached packages: [1] aplpack_1.3.0
I believe that the issue with loading tcltk is interfering with loading aplpack and that something in R.app/r-gui is not playing nicely with tcltk.
To my understanding
install.packages("tcltk")
Returns
package ‘tcltk’ is not available (for R version 3.2.3)
A work around would be to use the previous version of R which is compatible with tcltk.

DescTools package output to word document [duplicate]

This question already has answers here:
How should I deal with "package 'xxx' is not available (for R version x.y.z)" warning?
(18 answers)
Closed 8 years ago.
I am having trouble with outputting results using DescTools package to word document. Anybody was able to get output saved in a word document as intended in the package? I get the following error. Thank you in advance.
wrd<-GetNewWrd()
Loading required package: RDCOMClient
Failed with error: ‘package ‘RDCOMClient’ was built before R 3.0.0: please re-install it’
Error: require(RDCOMClient) is not TRUE
library(RDCOMClient)
Error: package ‘RDCOMClient’ was built before R 3.0.0: please re-install it
sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 LC_MONETARY=English_Canada.1252
[4] LC_NUMERIC=C LC_TIME=English_Canada.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] DescTools_0.99.8.1
loaded via a namespace (and not attached):
[1] boot_1.3-11 tcltk_3.1.0 tools_3.1.0
I installed RDCOMClient with no errors.
install.packages("//tsclient/D/user1/R packages/RDCOMClient_0.93-0.zip", repos = NULL)
Installing package into ‘C:/Users/user1/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
package ‘RDCOMClient’ successfully unpacked and MD5 sums checked
library(RDCOMClient)
Error: package ‘RDCOMClient’ was built before R 3.0.0: please re-install it
Downloading the source .tar.gz files from the RDCOM website, I was able to install the package by uncompressing the files and then using devtools::install. I'm a little out of date, using R 3.1.0, but it looks like you are too, so it should work as well.

Resources