readRDS "Cannot read workspace version ..." - r

For months I have been working with a script which gathers a bunch of tweets with Rtweets, does an rbind, and then saves the output to an .rds file with saveRDS. Up until now, I had no idea of this "version=" argument so I was not including it. But since last week, I have a problem where when ever I execute:
file <- readRDS("file.rds")
I get the following error:
Error in readRDS("bullshit.rds") :
cannot read workspace version 541346889 written by R 17741.73.84; need R 19777.84.83 or newer
I cannot figure out the solution. I saw something about updating packages, I tried that and it also was unsuccessful. I tried to find out which versions these are, but I cannot find any information about an R version 17741.73.84. I also tried with two different devices, and I got the same error.
Could anyone tell me what is going on, and how could I try fixing it? - It is more important for me to actually be able to read the file, and then I can try saving it on new ways, but the data is not salvageable if the file is lost (I will save it in multiple formats - learnt through the worst way i guess)
This is my current version:
> version
platform x86_64-w64-mingw32
arch x86_64
os mingw32
crt ucrt
system x86_64, mingw32
status
major 4
minor 2.1
year 2022
month 06
day 23
svn rev 82513
language R
version.string R version 4.2.1 (2022-06-23 ucrt)
nickname Funny-Looking Kid

Related

Recently updated R and RStudio and now ggplots will not plot on the plot pane, plots are opening on a new window. How can I fix this?

I recently updated R and RStudio and now all ggplots show up on a new pop-up window instead of on the plot pane. I updated R by using the updateR() function from the installr package. I then updated RStudio by going to Help -> Check for Updates. This is the only way I know how to update R and this is the first time I've encountered issues. This is happening on my Windows laptop but when I followed the same steps to update R and RStudio on my Windows work computer everything is working as expected, so only getting this issue on my laptop.
> version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
crt ucrt
system x86_64, mingw32
status
major 4
minor 2.1
year 2022
month 06
day 23
svn rev 82513
language R
version.string R version 4.2.1 (2022-06-23 ucrt)
nickname Funny-Looking Kid
When I load ggplot2 -> library(ggplot2) , I get the following warning
Warning message: R graphics engine version 15 is not supported by this
version of RStudio. The Plots tab will be disabled until a newer
version of RStudio is installed.
When plotting a ggplot, a new window named R Graphics: Device 2 (ACTIVE) pops-up with the plot. I would like to have my plots showing on the plots tab/pane instead of on a new window.
Screenshot of what I see when plotting ggplot (Actual figure hidden for privacy purposes)...
When I go to Help -> Check For Updates in RStudio it says "You're using the newest version of RStudio."
I tried re-installing ggplot2 but this did not help. In RStudio, I also checked Tools -> Check for Package Updates... and it seems like I have the latest ggplot2 version.
Is this a known problem with the latest R update (I don't think so since it works fine on my Windows work computer) or did something go wrong when updating? What should I try? I do not know what is the best way to unistall and re-install R (if this is something I should try).

How to view/change the installation of R that RStudio uses?

After installing either anaconda or jupyter, RStudio now shows some logs when installing packages, which indicate it's using R installed by anaconda, rather than the original version I had installed.
This is not a problem, until I try to install various packages, and I get some maze of frustrating c++ issues (due to graph dependencies).
What I've tried so far
Changed .libPaths() from the anaconda path to the default locations (but this doesn't help for R, only for R libraries)
Question
How can I tell which R installation RStudio is using, and how do I change it (from the anaconda version, back to the vanilla R version I previously had installed)
If you type version in the Rstudio console window it will tell you which version of R you are using...
> version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 6.3
year 2020
month 02
day 29
svn rev 77875
language R
version.string R version 3.6.3 (2020-02-29)
nickname Holding the Windsock
>
previous relaeases of R can be found here:
https://cran.r-project.org/bin/windows/base/old/
To those still searching for an answer and stumbled here
As listed above, basic info on the current R version is found entering this in the console of your RStudio
version
To view which R version is being used:
R.home() #tells you the R working directory
RSTUDIO_WHICH_R #tells you the source location of the R instance being used
Changing the version of R being used is much trickier. Consulting the official documentation can help, but realistically its easiest on Windows and a hassle on Mac/Linux. There might be some sneakier issues with Mac/Linux profiles and config variables, detailed more here
Best of luck!

RStudio empty at start

Seemingly out of nowhere, RStudio fails to start properly on my machine, creating a white small window, but nothing else.
I followed the advice here and here, but the problem persists. I reinstalled both R and RStudio to the latest version, tried to run in admin mode but nothing would help. Running version in R returns
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 6.0
year 2019
month 04
day 26
svn rev 76424
language R
version.string R version 3.6.0 (2019-04-26)
nickname Planting of a Tree
When I pres crtl while RStudio is starting it does ask me which R distribution to run, and the path which is stated there indeed exists and points to the R distribution which works just fine when you execute it directly.
Next, in C:\Users\myusername\Documents an empty RHISTORY file and a folder R containing a win-library folder which contains an empty folder called 3.5 (or 3.6 if I run it on R 3.6) gets created every I launch and close RStudio. Deleting these files does not help.
Finally, after installing an older RStudio version (1.0.153) it works!

Cannot run R from terminal after upgrading to macOS Sierra

I recently updated my macbook to macOS Sierra (Version 10.12.3 (16D32)), and I am no longer able to run R directly from Terminal:
DN51ssqi:~ kjytay$ R
-bash: R: command not found
DN51ssqi:~ kjytay$ R --version
-bash: R: command not found
Opening R from the Applications folder or from RStudio works fine. Anyone experience this issue/has been able to fix it?
Here is my R version information:
platform x86_64-apple-darwin13.4.0
arch x86_64
os darwin13.4.0
system x86_64, darwin13.4.0
status
major 3
minor 3.2
year 2016
month 10
day 31
svn rev 71607
language R
version.string R version 3.3.2 (2016-10-31)
nickname Sincere Pumpkin Patch
This is just a guess, but I'm thinking this is probably an issue with your PATH settings, which might have been overwritten when you upgraded*. Seems worth a try at least. This is from the RStudio support pages**:
R from source (including MacPorts and Homebrew)
When R is installed from CRAN on OS X the R executable is installed at
/usr/bin/R. However, if R is installed directly from source or via a
package manager like MacPorts or Homebrew, then the R executable is
installed to either /usr/local/bin/R (Homebrew) or /opt/local/bin/R
(MacPorts). In order to support these variations, RStudio scans for
the R executable in the following sequence:
/usr/bin/R
/usr/local/bin/R
/opt/local/bin/R
If RStudio is not able to locate R by scanning these locations, it
will fall back to using whatever version of R is located at
/Library/Frameworks/R.framework/.
If RStudio is finding R OK, then you must have it at one of these locations. Make sure these locations are in your $PATH list:
In the Terminal:
echo $PATH
Will display your current PATHs list. If any of the locations in the RStudio quote are missing, you can see if that's where R is located by trying to specify that location. For example:
/usr/local/bin/R
If that works to start R, just add that location to your PATHs list:
export PATH=$PATH:/usr/local/bin
So that OSX knows where to find it!
* It's been noted elsewhere that homebrew breaks, for example, on upgrade to Sierra. Here's a blog post outlining some steps an R user might like to take after the upgrade: http://www.statsblogs.com/2017/01/26/upgrading-to-macos-sierra-nee-osx-for-r-users/
** Here's the support page where the quote is from https://support.rstudio.com/hc/en-us/articles/200486138-Using-Different-Versions-of-R

dyn.load crashes without any clue

I tried to use dyn.load command for loading external dll libraries, but it close my R session after running the command every time. I'm using windows 10 and here is my R version:
version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 1.3
year 2015
month 03
day 09
svn rev 67962
language R
version.string R version 3.1.3 (2015-03-09)
nickname Smooth Sidewalk
to test this, here is a simple code to lock screen using windows native dll:
dyn.load("C:\\Windows\\System32\\user32.dll")
.Call("LockWorkStation")
It is locking my screen, but when I log in back, my R session is crashing.
dyn.load() is not meant to be a way to load DLLs in general, but rather to load DLLs created by R's compiler tool chain as described in the Writing R Extensions manual.
DLLs can be used by linking to them in the Makevars.win file
PKG_LIBS = -L$(XXX_DIR)/lib -lxxx
as discussed at the end of section 1.2.1 Using Makevars, but this implies writing C wrappers around the DLL.
I'm not an expert on Windows and R, and it's unusual in R to rely on platform-specific libraries, so please take my comments with a grain of salt.
It seems it is going to work if I change .Call to .C.
I conclude if you know how to run functions in DLL (using .Call, .C, .External or maybe .Fortran)you can use general DLLs in R.

Resources