Running strapply in the absence of tcltk in R - r

I have a data frame with one column carrying a list variable. The list variable contains duplicate elements which I want to remove. The following is the code that I am using:
library(gsubfn)
Loading required package: proto
Could not load tcltk. Will use slower R code instead.
resp$secu <- as.character(lapply(strapply(resp[[7]], "\\w")), unique)
I am using R 3.2.0 version on mac. I tried loading tcltk manually without success:
library(tcltk)
Error : .onLoad failed in loadNamespace() for 'tcltk', details:
call: fun(libname, pkgname)
error: X11 library is missing: install XQuartz from xquartz.macosforge.org
Error: package or namespace load failed for ‘tcltk’
I uninstalled library tcltk and tried re-installing but couldn't:
Warning in install.packages :
package ‘tcltk’ is not available (for R version 3.2.0)
I could execute the code and R started without any error messages. But it had taken an hour for a 65k row list to remove the duplicates and the processing yet to complete. Is there a way to improve the speed of strapply without using tcltk library?

Related

R tcl issue on shared HPC cluster environment

I've been having some issues getting R to run properly on the shared cluster at my institution , where i don't have root access. Some things will work but it gets tricky when i need to install packages etc. The current issue i'm trying to trouble shoot is the following error when trying to load the caret package:
Loading required package: lattice
Loading required package: ggplot2
Error: package or namespace load failed for ‘ggplot2’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/cifs/hariri-long/Scripts/Tools/R/packages/rlang/libs/rlang.so':
/cifs/hariri-long/Scripts/Tools/R/packages/rlang/libs/rlang.so: undefined symbol: R_removeVarFromFrame
Error: package ‘ggplot2’ could not be loaded
Execution halted
I found this page suggesting i install rlang as follows:
> install.packages("rlang",type="source")
Installing package into ‘/cifs/hariri-long/Scripts/Tools/R/packages’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Error: .onLoad failed in loadNamespace() for 'tcltk', details:
call: fun(libname, pkgname)
error: Can't find a usable init.tcl in the following directories:
/usr/share/tcl8.5 ./lib/tcl8.5 ./lib/tcl8.5 ./library ./library ./tcl8.5.13/library ./tcl8.5.13/library
but i get the above tcl error. since i've seen this in other threads:
> capabilities("tcltk")
tcltk
TRUE
it looks like tcl on my system is 8.6, but i don't know how to tell R to look for that version.
$ whereis tcl
tcl: /usr/lib64/tcl8.6 /usr/include/tcl.h /usr/share/tcl8.6
$ which R
/opt/apps/rhel7/R-3.6.0/bin/R
Any ideas? The OS is CentOS 8. Thanks!
I ended up deciding to try using a more recent R version (4.1.1) to solve this issue. I was hesitant to do this at first because I have run into issues with availability / compatibility of packages I need in more recent R versions, but I wasn't getting anywhere troubleshooting this issue otherwise. I figured that since TCL 8.6 is what was installed on the system, a newer version of R might be able to work with it, and seems i was right, since I got past the first error I was having when I switched.
I did get a new error regarding an issue loading the shared library Libtk8.6.so. So I downloaded the .so file from here and unpacked it to my home directory using rpm2cpio (i don't have root access so i can't just use yum install etc). After that i just had to re-install all my packages for the new R version and it worked!

choroplethr package in R will not load [duplicate]

This question already has answers here:
Rcpp package doesn't include Rcpp_precious_remove
(2 answers)
Closed last year.
Loading required package: acs
Loading required package: stringr
Loading required package: XML
Attaching package: ‘acs’
The following object is masked from ‘package:base’:
apply
Error: package or namespace load failed for ‘choroplethr’:
.onLoad failed in loadNamespace() for 'units', details:
call: udunits_init(path)
error: function 'Rcpp_precious_remove' not provided by package 'Rcpp'
In addition: Warning messages:
1: package ‘choroplethr’ was built under R version 4.0.5
2: package ‘acs’ was built under R version 4.0.5
3: package ‘XML’ was built under R version 4.0.5
As #jose pointed out in the comments, this can likely be solved by updating your packages. The error you copied is quite long, but the key part appears to be this:
error: function 'Rcpp_precious_remove' not provided by package 'Rcpp'
I am actually the author of choroplethr, and I have no idea what this function is, or why Rcpp is being loaded at all when you load choroplethr. But here we are.
When I paste that error message into DuckDuckGo, the first hit I get is this stackoverflow question.
There the solution appears to simply be typing:
install.packages('Rcpp')
library(Rcpp)
I recommend trying that and seeing if it works.
Regardless of whether that alone solves your problem, I also recommend following the other suggestion #jose made. Namely, typing:
update.packages()
And trying again.
Dependency management in R is a pain. It is probably worth getting into the habit of typing update.packages() when you get an error you don't recognize to see if it magically solves your problem.

Rcmndr plugin not running

I am trying to run this rcmndr plugin for my class and it's not working. I installed all the necessary packages and it appeared to install correctly but I am getting this package or namespace load failure. The GUI appears for a split second when I enter the library command, then disappears with the error. It seems to be an issue with the namespace and .onattach but I couldn't find any existing answers or resources for this issue.
https://cran.r-project.org/web/packages/RcmdrPlugin.BCA/index.html
> library(RcmdrPlugin.BCA)
Loading required package: Rcmdr
Loading required package: splines
Loading required package: RcmdrMisc
Loading required package: car
Loading required package: sandwich
Rcmdr Version 2.2-3
Loading required package: BCA
Warning: package 'BCA' was built under R version 3.2.3
Loading required package: flexclust
Warning: package 'flexclust' was built under R version 3.2.3
Loading required package: grid
Loading required package: lattice
Loading required package: modeltools
Loading required package: stats4
Error : .onAttach failed in attachNamespace() for 'RcmdrPlugin.BCA', details:
call: get(Menus[m, 5])
error: object 'importRODBCtable' not found
In addition: Warning messages:
1: package ‘RcmdrPlugin.BCA’ was built under R version 3.2.3
2: package ‘Rcmdr’ was built under R version 3.2.3
3: package ‘RcmdrMisc’ was built under R version 3.2.3
4: package ‘car’ was built under R version 3.2.3
Error: package or namespace load failed for 'RcmdrPlugin.BCA'
I got alternative to run this plugin in R commander.
Open R Commander by using:
library(Rcmdr)
R Commander dialogue box will appear.
In R Script load BCA library-
lapply(list('BCA', 'splines', 'RcmdrMisc', 'car', 'sandwich', 'flexclust', 'grid','lattice','modeltools','stats4','RODBC'), require, character.only = TRUE)
Click on Submit button.
If you don't have RODBC package (which is not there in my case), install it separately and then run above commands. To install use:
install.packages("RODBC")
And now you exactly have what you will get after loading RcmdrPlugin.BCA library.
I faced a similar situation. Having tried a bunch of things - none worked - I finally uninstalled R and deleted the remaining files from under the "Program Files" directory in Windows. I then reinstalled R and RcmdrPlugin.BCA and this time it worked.
You could also refer to this URL for help http://r.789695.n4.nabble.com/Unable-to-run-RcmdrPlugin-survival-using-3-2-2-with-Windows-10-td4711796.html

Rcmdr Error : .onLoad failed in loadNamespace() for 'tcltk'

I have no idea what I'm doing but I need to use R and Rcmdr for my statistics class. I am running OS X 10.7.5, using 3.1.2 for R.
I have downloaded R.
install.packages("Rcmdr")
Picked a mirror, downloaded all packages. I then typed in
library(Rcmdr)
And received this error:
Loading required package: splines
Loading required package: RcmdrMisc
Loading required package: car
Loading required package: sandwich
Error : .onLoad failed in loadNamespace() for 'tcltk', details:
call: system2("otool", c("-L", shQuote(DLL)), stdout = TRUE)
error: error in running command
Error: package or namespace load failed for ‘Rcmdr’
sh: otool: command not found
When I do:
capabilities("tcltk")
# [1] TRUE
Have I done something wrong?
The R developers have tried to make a workaround for R not giving a useful error message when Tcl/Tk was not fully supported on a Mac. It seems R 3.1.2 depends on the otool from Xtools for this. However, you can download a patched version of R from http://r.research.att.com/ to remove the error.

tcltk in portable R

I am using portable R and I want to try the sqldf package a bit, I can load the sqldf package, but running a sql statement and gives me this message:
> sqldf("select * from BOD where Time > 4")
Loading required package: tcltk
Loading Tcl/Tk interface ...Error : .onLoad failed in loadNamespace() for 'tcltk', details:
call: NULL
error: Tcl/Tk support files were not installed
Error: require(tcltk) is not TRUE
I have looked for solutions but most of them suggest me to install R, which is not possible as I am using portable R.
What can I do? Thanks.
install R 2.13.1 for Windows, copy ~/R-2.13.1/Tcl folder to ~\R-Portable\App\R-2.11.1
and
~/R-2.13.1/library/tcltk folder to ~/R-Portable/App/Data/library
I tried and it works.
See sqldf FAQ #5

Resources