What causes the error when using ggplot plot on different OSes? - r

I'm getting a strange error when loading .Rdata produced on one OS and transferred to another. On a Windows machine I generate a large number of plots and store them in a .Rdata file. I then transfer them to a linux server running CentOS 5 and access them by loading the file and recalling the plot.
When I run the following lines on CentOS I get an error:
library(ggplot2)
load('mydata.Rdata')
p
Error in UseMethod("facet_train_layout") :
no applicable method for 'facet_train_layout' applied to an object of class "c('proto', 'environment')"
The Windows 7 OS that was used to produce this .Rdata file is using the following version of R:
R version 2.14.2 (2012-02-29) Copyright (C) 2012 The R Foundation for
Statistical Computing ISBN 3-900051-07-0 Platform:
x86_64-pc-mingw32/x64 (64-bit)
The CentOS system that produces an error is as follows:
R version 2.14.2 (2012-02-29) Copyright (C) 2012 The R Foundation for
Statistical Computing ISBN 3-900051-07-0 Platform: i686-pc-linux-gnu
(32-bit)
The ggplot2 version on both systems is ggplot2_0.9.2.1. This process has worked fine for the last six months, the only problem has been today due to an update and I don't understand what is going wrong.
Both versions of R were upgraded to 2.14.2, as well as the ggplot package to ggplot2_0.9.2.1.

I presume the old version was 0.8.9 or below. There was a fundamental change with version 0.9.0:
FACETS
Converted from proto to S3 objects, and class methods (somewhat) documented in facet.r. This should make it easier to develop new
types of facetting specifications.
See http://cran.r-project.org/web/packages/ggplot2/NEWS for more information

Related

can you print/echo message from .Renviron?

It is possible to print messages from .Renviron so it is shown in RStudio at startup?
For example:
R_LIBS_USER="C:/Rlib/"
APIKEY="blabla"
echo Company envvar set
I don't want to use .Rprofile as that is overwriten in projects.
EDIT:
This is on locally installed R on windows. We roll out R/Rstudio/Rtools in a software package to all members of a certain AD group. It is in this process that I would like to do some configurations and information.
As noted above you could set environment variables in R/R-4.x.x/etc/Renviron.site to set these for all users, even when projects are involved:
hello_message = "Hello! This has worked!"
Then set R/R-4.x.x/etc/Rprofile.site to print these variables:
message(Sys.getenv("hello_message"))
Then starting a new session, inside outside of a project will set all variables and print all messages:
R version 4.1.2 (2021-11-01) -- "Bird Hippie"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
...
Hello! This has worked!
>

RStudio not loading RevoScaleR on Ubuntu 16.04

Long story short:
Calling rxImport() works fine in a Terminal R session but fails when using RStudio, despite using the same installation of R.
Setup:
I'd like to use RevoScaleR functions like rxImport(...) on Ubuntu. I have an installation of RStudio and R done through package manager.
I've installed MS Rclient following the instructions here.
Everything seems to work as I can run in the terminal:
/opt/microsoft/rclient/3.4.3/bin/R$ ./R
R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
...
Microsoft R Open 3.4.3
The enhanced R distribution from Microsoft
Microsoft packages Copyright (C) 2018 Microsoft
Loading Microsoft R Client packages, version 3.4.3.0097.
Microsoft R Client limits some functions to available memory.
See: https://go.microsoft.com/fwlink/?linkid=799476 for information
about additional features.
...
Using the Intel MKL for parallel mathematical computing (using 2 cores).
Default CRAN mirror snapshot taken on 2018-01-01.
See: https://mran.microsoft.com/.
> R.home()
[1] "/opt/microsoft/rclient/3.4.3/runtime/R"
> rxImport()
Error in rxImport() : 'inData' must be specified.
So the function is loaded and available by default. Now I tell the RStudio to use this installation of R by adding the following at the end of ~/.profile :
RSTUDIO_WHICH_R="/opt/microsoft/rclient/3.4.3/bin/R/R"
Error:
When I run rstudio I get a R console in the IDE saying:
> R.home()
[1] "/opt/microsoft/rclient/3.4.3/runtime/R"
> rxImport()
Error in rxImport() : could not find function "rxImport"
Possible causes
I've found some threads with people complaining about MS packages not dealing properly with ~ and working directory (i.e. on a remote server), setwd() doesn't solve my issue, though.
Do you have any ideas on how to get RevoScaleR to work with RStudio? Thanks in advance.
An answer I got from Github:
https://github.com/rstudio/rstudio/issues/2455#issuecomment-375327109
try setting
R_LIBS_SITE=/opt/microsoft/rclient/3.4.3/libraries/RServer
in
/opt/microsoft/rclient/3.4.3/runtime/R/etc/Renviron

R Bioconductor package error on Linux (GenomicFeatures)

I want to use the function "makeTxDbfromGFF", which is part of the GenomicFeatures package. This function used to work perfectly until now, I get the following output:
makeTxDbFromGFF("/file/to/gencode.v19.annotation.gtf", dataSource="Gencode", organism="Homo sapiens", format="gtf")
>Import genomic features from the file as a GRanges object ... OK
>Prepare the 'metadata' data frame ... OK
>Make the TxDb object ... Error in c(x, value) :
could not find symbol "recursive" in environment of the generic function
This function works on my Mac, but not on my Linux workstation. Here some details to my session:
R version 3.3.3 (2017-03-06)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.1 LTS
I already uninstalled the new version 1.26.3 and installed the previous version (1.24.5), but I get the same error. On my Mac I use the version 1.26.2.
My research so far was not very successful. I just found out it might be due to some inconsistency with other software/packages(?).

Two different R versions and invoking of older R version

I recently installed latest version of R(3.3.1) on my mac but somehow the R is still pointing to the old R version which I had. When R is invoked in command line it show the new version but on typing version in R environmnet the older(3.0.2) is shown.
What changes should be made so as to update to newer R version?
Also I deleted previous versions directories from Frameworks.
Additionally probably because of this issue I get an error when I start R studio.
ls /Library/Frameworks/R.framework/Versions/
3.3 Current
===========================
user1#my-mac:~$ R
Error in objects(db.pos, all.names = TRUE) :
2 arguments passed to .Internal(ls) which requires 3
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin13.4.0 (64-bit)
....
....
Error in gzfile(file) : invalid 'encoding' argument
During startup - Warning message:
unable to restore saved data in .RData
> version
_
platform x86_64-apple-darwin10.8.0
arch x86_64
os darwin10.8.0
system x86_64, darwin10.8.0
status
major 3
minor 0.2
year 2013
month 09
day 25
svn rev 63987
language R
version.string R version 3.0.2 (2013-09-25)
nickname Frisbee Sailing
In Mac, point rstudio to the newer version of R using the RSTUDIO_WHICH_R environment variable.
export RSTUDIO_WHICH_R=/usr/local/bin/R

glm running out of memory in 64-bit R?

I am trying to run glm on a dataset with 255001 data points, but it's saying
Error: cannot allocate vector of size 10.0 Gb
This is very strange because when I start up R, I see the message
R version 3.1.1 (2014-07-10) -- "Sock it to Me"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
Which seems to indicate that I'm running a 64 bit version of R, and I read that the memory limit for 64 bit versions of R on Unix is on the order of 128 Tb.
Furthermore, I have successfully run glm logistic regression on very similar datasets that are twice as large without any problem.
How can I reconcile these facts, and how can I get R to hold large objects in memory?
It turns out there was a bug in my code, and when I was reading in the data, I set header=FALSE instead of header=TRUE. Changing this fixed the problem.

Resources