RStudio empty at start - r

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!

Related

readRDS "Cannot read workspace version ..."

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

Emacs and R - Emacs closes when using tk_choose.dir

I'm using R scripts inside Emacs on Windows 10 Enterprise to analyze data. It works well but recently after sending a tk_choose.dir command, emacs closes (but not R ; the script keeps on running after choosing the folder).
If someone can tell me the result of the following command :
library(tcltk)
c_folder <- tk_choose.dir("c:/")
If needed, here is the output of the version command:
version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 4
minor 1.3
year 2022
month 03
day 10
svn rev 81868
language R
version.string R version 4.1.3 (2022-03-10)
nickname One Push-Up
Thanks in advance for your help,
Newb'R

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!

Using a new windows version of R in Jupyter notebooks

I've installed R version 3.5.1 for windows and copied its contents to the R folder used by Anaconda3. However conda still identifies the current version as 3.4.3. Is there a "version id" file somewhere in the Anaconda3 folders?
Short solution
In short you need to install a the IRkernel package in the version of R you want to use with Jupyter and then make it available to Jupyter. See here.
Diagnosis
You may not be aware that you have two installations of R. To confirm this is the case in a Jupyter Notebook, type:
R.version
This should return values such as:
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 4.3
year 2017
month 11
day 30
svn rev 73796
language R
version.string R version 3.4.3 (2017-11-30)
nickname Kite-Eating Tree
Now open RStudio or RGui and input the same command, you should see different output (ignore any warnings):
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 5.0
year 2018
month 04
day 23
svn rev 74626
language R
version.string R version 3.5.0 (2018-04-23)
nickname Joy in Playing
Note the differences in the version.string and nickname variables in particular.
Now in your Jupyter notebook type:
R.home()
Which will give the output like:
"C:/Anaconda3/lib/R"
The same command in RStudio or RGui will return a different path e.g.:
"C:/R/R-35~1.0"
The above values may not match those on your machine, but if they are different to each other the following steps will allow you to use the latest R instance from Jupyter.
Longer solution
Copy the above R.home() path from Rstudio (or RGui)
Open Anaconda Prompt form the start menu
Type cd /d "C:/R/R-35~1.0" where the path is the same as the one you have copied. Hit return.
Type cd bin. Hit return
Type R.exe to launch the command line R from that directory
We now need to install the package IRkernel. This package makes the version of R callable as an Jupyter kernel. Type install.packages('IRkernel') and hit return.
Type IRkernel::installspec(name = 'ir35', displayname = 'R 3.5.0') to create the latest R kernel. Note you can change the name and display name to be whatever you wish.
Exit R and close any instances of Jupyter Notebooks you have running.
Launch Jupyter Notebook again and click to create a new notebook. You should find your kernel available by its display name in the drop down box.

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

Resources