tcltk dependency when trying to use ordPens library in Anaconda R - r

I've been wrestling with this for days, and while there seem to be a number of tcltk problems in StackOverflow, I can't find the key to unlock this. Hope someone can help.
I'm using Anaconda and Jupyter notebooks to access R. I'm running this on Windows 10. It works wonderfully most of the time. I'm trying to use the ordPens package, but when I call the library, I get an error. The error seems to be that it requires the tcltk package to be loaded, to use the ordPens package.
library(ordPens, verbose=TRUE)
Warning message in find.package(package, lib.loc, quiet = TRUE, verbose = verbose):
"package 'ordPens' found more than once,
using the one found in 'C:/Program Files/R/R-3.3.0/library/ordPens'"Warning message:
"package 'ordPens' was built under R version 3.3.2"Loading required package: tcltk
Error: package 'tcltk' could not be loaded
Traceback:
library(ordPens, verbose = TRUE)
.getRequiredPackages2(pkgInfo, quietly = quietly)
stop(gettextf("package %s could not be loaded", sQuote(pkg)),
. call. = FALSE, domain = NA)
But tcltk can't be installed directly, as a normal package. Apparently this causes problems in non-WIndows environments, when it isn't always loaded at initial build. But tcltk does appear to be available.
capabilities("tcltk")
tcltk: TRUE
I tried a workaround by installing ordPens into the directory used by my R console, rather than Anaconda, and then pointing Anaconda at that (drawing on this post, which has helped in the past) :
.libPaths('C:/Program Files/R/R-3.3.0/library')
but it still didn't work.
Any ideas? As a last resort, I could just save my outputs from the Jupyter/Anaconda environment, process them with ordPens in the R console, and then save back. But I'd love to know how to fix this - and really to understand what is going on.

Related

Bioconductor update keeps failing to update after a half hour

I'm working with R and need to install some packages.
> BiocManager::install( c( list, of, packages) )
Error: Bioconductor version '3.13' requires R version '4.1'; use
`BiocManager::install(version = '3.16')` with R version 4.2; see
https://bioconductor.org/install
ok, so I need to update bioconductor. No problem:
BiocManager::install(version = '3.16')
At this point I get an absolute torrent of text output to my terminal for over half an hour. It ends with this:
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (ggpubr)
The downloaded source packages are in
‘/tmp/Rtmpu3HGq9/downloaded_packages’
Error in .install_github(todo, lib = lib, lib.loc = lib.loc, repos = repos, :
argument "update" is missing, with no default
In addition: Warning message:
package(s) not installed when version(s) same as or greater than current; use
`force = TRUE` to re-install: 'BiocVersion'
So I do it again with the "force" option, but the process insists on starting all over again from scratch, so I have to wait another half-hour and get the same problem. I've done this almost a dozen times now with variations on the command and environment settings and this is eating up days of work time.
I also noticed another message in the output:
Warning: unable to access index for repository https://bioconductor.org/packages/3.16/bioc/src/contrib:
cannot open URL 'https://bioconductor.org/packages/3.16/bioc/src/contrib/PACKAGES'
Am I being blocked by some internal network? I've also tried setting a proxy with Sys.setenv(http_proxy="[proxyAddress]:[port]")
To no avail.
I'm Running out of ideas and would much appreciate any help.
This issue is discussed here: https://github.com/Bioconductor/BiocManager/issues/142. Basically it will be fixed in the next release of BiocManager, which is whatever comes after 1.30.19.

Cannot install rstanarm (R crashes)

A similar question was asked here, but I tried the code Tiago Lubiana posts there, to no avail.
I haven't been able to install rstanarm after several attempts. R keeps crashing during the installation.
I did install rstan by running
install.packages("rstan", repos = "https://cloud.r-project.org/", dependencies = TRUE)
When I want to install rstanarm, nothing seems to work, though. I've tried the following:
1) install.packages("rstanarm"): R crashes and installs a folder called 00LOCK-rstanarm, plus the corresponding rstanarm folder. When I open R, rstanarm is there, but after running library(rstanarm), I get
Error: package or namespace load failed for ‘rstanarm’ in library.dynam(lib, package, package.lib):
shared object ‘rstanarm.so’ not found
By running install.packages("rstanarm") again, I get:
ERROR: failed to lock directory ‘/home/nalerive/R/x86_64-pc-linux-gnu-library/3.5’ for modifying
Try removing ‘/home/nalerive/R/x86_64-pc-linux-gnu-library/3.5/00LOCK-rstanarm’
Warning in install.packages :
installation of package ‘rstanarm’ had non-zero exit status
Deleting that folder has not solved the problem (but see here for a similar error with another package).
2) From here, running
if (!require(devtools)) { install.packages("devtools")
library(devtools) }
install_github("stan-dev/rstanarm", build_vignettes = FALSE)
leads to R crashing again, and the same folders as in 1) are installed. I also get the same error by running library("rstanarm"), namely:
Error: package or namespace load failed for ‘rstanarm’ in library.dynam(lib, package, package.lib):
shared object ‘rstanarm.so’ not found
3) Following this post I tried
install.packages("rstanarm", dependencies = TRUE, repos="http://cran.rstudio.com/", INSTALL_opts = c('--no-lock'))
and R keeps crashing.
I've tried more things, like removing the 00LOCK-rstanarm folder by means of unlink("/home/nalerive/R/x86_64-pc-linux-gnu-library/3.5/00LOCK-rstanarm/", recursive = TRUE); restarting R when indicated; checking my C++ toolchain (as suggested here), etc... but nothing has worked. I really feel hopeless at this point.
I have R version 3.5.2, rstan version 2.19.2, and Linux 4.15.0-1-amd64 #1 SMP Debian 4.15.4-1~mx17+1 (2018-02-23)
Any help will be highly appreciated. Thanks in advance!

Issue with loading Tidyverse in RStudio

How to do i resolve the following code error?
library(tidyverse)
Error: package or namespace load failed for ‘tidyverse’:
.onLoad failed in loadNamespace() for 'tidyselect', details:
call: is_string(x)
error: object 'rlang_is_string' not found
In addition: Warning message:
package ‘tidyverse’ was built under R version 3.5.3
For persistent errors of type, first, ensure you are working with the latest version of R. The installr package is a very convenient way to do this.
Then, start new R session (ideally, not in RStudio).
Uninstall tidyverse, tidyselect, and rlang
# if you are using multiple libraries, you may need to specify libpath,
# using the following: lib="~/R/win-library/3.6"
# you can check using the .libPaths() command
remove.packages("rlang")
remove.packages("tidyselect")
remove.packages("tidyverse")
and, reinstall them one by one with dependencies = TRUE
install.packages("rlang", dependencies = TRUE)
install.packages("tidyselect", dependencies = TRUE)
install.packages("tidyverse", dependencies = TRUE)
That should do it.
I also encounter a similar problem like you, which I'm unable to load the tidyverse too.
Hope this discuss from the tidyverse github issues maybe relevant to you.
https://github.com/tidyverse/googledrive/issues/275
Here's one of our typical explanations of this. Note that this is not specific to googledrive or rlang. It's an R + Windows gotcha. I suspect for you is rlang (at least).
Please note that on Windows, it is very important to quit or restart
all R processes before upgrading , because if any R process has
loaded, it will keep the .dll file open and the installer will not be
able to overwrite .dll. The error message when this happens is very
easy to overlook, and the new version will be partially installed: the
package description and R code will be updated but the compiled code
(in .dll) will not.

R 3.0.1 package build warning

I'm building R packages in R 3.0.1 on a Windows machine, using Rtools30 and the 'Build' tools associated with RStudio, which I assume is tied in with devtools (which is up-to-date). My typical process to build a package is:
Load All
Reoxygenize
Build & Reload
Check
Build Source Package
If everything goes without errors or warnings, I then:
install.packages("foo.tar.gz", repos=NULL, type="source")
Since upgrading to R 3.0.1, I now get this warning:
Warning in install.packages :
foo.tar.gz is not available (for R version 3.0.1)
I also tried before installing, and it did not get rid of the warning:
options(install.packages.check.source = FALSE)
Also, I notice this warning when I open the devtools library:
WARNING: Rtools 3.0 found on the path at c:/Rtools is not compatible with R 3.0.1.
Which is weird, Rtools 3.0 is suppose to be good from R >2.15.1 to R 3.0.x
Any ideas what is going on?
This is RStudio specific, as they wrap and/or changed a lot of functions from the utils for better integration. The problem lies with a call to getDependencies() to check for dependencies. But that function will also check whether the original package exists on CRAN and throws the given warning when it doesn't. A package you just built on your own computer is obviously not on CRAN, hence the warning.
In the source of the native install.packages(), getDependencies() isn't called in case you build from source or install from a different repository respectively. RStudio on the other hand calls getDependencies() before it passes everything on to the native install.packages() function.
This has to my knowledge no further effects, apart from confusing people. I didn't find a way to conveniently get rid of this in RStudio, as suppressWarnings() doesn't work in this context due to the complex way RStudio deals with this.
In a basic R console, you shouldn't have any problem.
So for the time being, I'd just ignore this and hope the RStudio team finds time to take care of this minor glitch.

error with R CMD check because of package dependency

Background
I am creating a newpackage that depends on oldpackage, and have indicated this dependency in the file newpackage/DESCRIPTION.
Furthermore,
oldpackage is installed in the directory, ~/lib/R
my .Rprofile includes .libPaths("~/lib/R")
hence, I can successfully load oldpackage without specifying the library location, e.g., using the command library(oldpackage) in R
Despite the ability to load the package without having its library specified, R CMD check newpackage gives an error indicating that it can not fine oldpackage:
checking whether the package can be loaded ... ERROR
Loading required package: oldpackage
Error: package 'oldpackage' 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 'oldpackage'
Execution halted
It looks like this package has a loading problem: see the messages for
details.
Questions:
Why is R unable to find the package?
Can I specify the library location in the DESCRIPTION file?
Regarding question 1), it is both a FAQ and yet somewhat annoying. R CMD check runs in vanilla mode, so it will not find user-level libraries. As I recall, setting R_LIBS="...." in the call helps, so try that.
Regarding question 2), no you cannot give a location in DESCRIPTION. Which makes sense as that file needs to work 'everywhere' whereas your location info is local to your machine.

Resources