How should I upgrade R properly to keep older versions running [Windows]? - r

I more or less follow this guideline:
Run installr::updater() from ../R-4.0.0/bin/x64/Rgui.exe (as suggested if you run it from RStudio)
Update all packages (check the "update all packages" box from installr::updater())
Change Windows system environment variable R_LIBS in my case to ..\R\R-4.0.x\library.
If I want to switch the R vesion from RStudio, I need to
Set Tools -> Global Options -> General -> R version AND
change R_LIBS to the correct place. (If you forget this, .libPaths() has more than one entry.)
So my questions are:
Is that process correct? Do I miss anything?
What about changing Rtools when switching between major R-versions, see e.g. here?
It seems installr::updater() does not update the packages, although I check the "update all packages" box. (We observed that behaviour on two different laptops.)
It seems, .Rprofile, .Renviron, and Rprofile.site play a crucial role, see RStudio. Last time, everything worked fine, .Rprofile and .Renviron were empty and I had to add the line .libPaths("path2/R-4.0.4/library") to Rprofile.site. It seems you can use usethis::edit_r_profile() to finde those files.
Background: I had this question which was reproducible before I upgraded R to 4.0.2, but I realized, that after switching between
R 3.5.1, 4.0.0 and 4.0.2 back and forth for testing it is not reproducible anymore.
Thus I think, that my update-process was error-prone.

Two years later, I more or less follow this process with success:
(Windows: Make sure R and RStudio are located C:\. Otherwise you run in trouble with .libPaths()!)
Run installr::updater() from C:/R-4.x.y/bin/x64/Rgui.exe (as suggested if you run it from RStudio)
Update Windows PATH variables
Update all packages (check the "update all packages" box from installr::updater())
Keep packages at the old R-version if you like
If you follow this process, R_LIBS, .Rprofile, and .Renviron should have no impact (it seems).

Related

Rstudio and R in command window in anaconda have different enviroments

I have a confusion when using R inAanaconda. I created an environment called "rstudio_env" and installed Rstudio in this environment. So far so good.
When I use Rstudio, I just open it without activating the "rstudio_env" and I also installed a lot of packages here. After updating the R through Rstudio, my new home path in Rstudio changes to some local default path. For example, the original .libPaths() = "C:/Users/someuser/.conda/envs/rstudio/lib/R/library" and new .libPaths()= "C:/someuser/Document/R/R-4.0.2/library".
Now when I use Rstudio, I have the new path. When I use R in the "rstudio_env" in conda, I still have the old path. This really confuses me, because I want to have the same libraries for both approaches. Why the updating changes the path of RStudio rather than only updating the contents?
I am too lazy to activate the "rstudio_env" when using Rstudio. That might be the reason for the conflict. But for now, how can I make the libraries consistent? I know I can change .libPaths manually, but are there other ways, some clearer ways?
I just reinstalled everything and made everything clean

R plot doesn't work on my Windows, but plot.default does

I'm taking a course in R and I've hit a road block on day one.
Typing:
demo(graphics)
...should start a series of graphs being displayed on screen. On my Windows 10 (64 bit) new Dell laptop, I get a persistent error:
The execution is stopped after the red lines, seemingly because the demo(graphics) call is being made with incompatible parameters. In blue I make the same call but use the default function and an empty plot is displayed.
I have tried uninstalling and reinstalling everything, installing through Anaconda and from the CRAN website. The same error persists. I've even tried with mro instead of basic R.
I don't see any similar error messages in my class or on Google. My guess is that I need to install a particular version of R and RStudio make it work but I'm guessing.
Can anybody offer some expertise?
I'm running R version 3.6.1 (2019-07-05) (which is executing code correct, just not the demo call) and RStudio Version
Running the basic Rgui software from the command line with the --vanilla parameter like so:
Rgui --vanilla
Opened Rgui and the
demo(graphics)
...call worked.
This meant that the issue was in the .Rprofile file. This is found in the etc folder of the basic R installation and when I checked, it looked absolutely fine (entirely commented out actually).
I wanted to use RStudio though, so I investigated the RStudio docs and saw that each project is given its own .Rprofile style initialization file when a new project is created.
So I created a new project with RStudio and by creating a new project whatever configuration issue was causing the error was completely fixed.
Credits to G. Grothendieck for the answer in the comments.

How to update to Julia 0.7 on MacOs without installing packages again

I am a user of Julia v0.6, no issues to report. I am trying to update to Julia v0.7. I already have the CMD line version installed.
I copied the packages over from the v0.6 folder into my packages folder that came with v0.7.
Here is an image of my file structure in finder.
I see the packages in the "Packages" folder you see above. However, when I try "using SHERPA" for example(SHERPA is a package in the "Packages" folder), it says it's not installed. I thought maybe Pkg.init() would fix the problem but that command is deprecated on v0.7 so I don't know what to do.
I have already looked at the other StackOverflow questions and those didn't resolve my issue. I also already tried Pkg.resolve() and Pkg.Update() to no avail.
I appreciate your support.
Edit W/Solution:
At the time of this writing, I am running MacOs Mojave on my Mac and would suggest at least MacOs High Sierra since the file structure was changed in there.
Install Julia 0.7: https://julialang.org/downloads/ Note: if you don't see v0.7 on the link above, go here: https://julialang.org/downloads/oldreleases.html
Once v0.7 is installed, make sure it dragged into your application folder.
Run the program. Type "Pkg.resolve()" and "Pkg.Update()" in the Julia Terminal window that appears.
Then Run:
Pkg.add("JSON")
in order to get your packages file to show up...
This should make it so the new package management system is enabled. You can confirm that by checking your ".julia" folder(which can be accessed but going to finder - clicking Command-Shift-H and then Command-Shift-.)
You should see an "environments", "packages" and "registries" folder(in addition to probably a few others). Note as of now, due to the new package manager, you either cannot or I don't know how to, clone a project from GitHub desktop to your packages folder.
To add a custom-made package: open command line version v0.7
Type "]". You should see "(v0.7) pkg> " in blue text. Note use "Control"-"c" to exit Pkg mode in terminal.
Type " add https://github.com/xxxxxxx/xxxxxxx.git"
Type " add https://github.com/xxxxxx/xxxxxxx.git" Note: follow any on-screen prompts(i.e. "Type PKg.resolve() or Pkg.update()")
Note: you will probably see many depreciation warning when you run your old code.
How to use the new Pkg manager in Julia v0.7: https://docs.julialang.org/en/v1/stdlib/Pkg/index.html
This is not possible and/or not recommended for the following reasons:
The package manager is completely new in Julia v0.7/v1.0 compared to the one in Julia v0.6. In particular, the new package manager does not understand the old package managers folder structure and method of installation (git cloning). As a sidenote, the packages folder is not supposed to be modified by users, it is controlled by Pkg, and, in particular, putting something in the packages folder does not mean it is installed.
Since there have been very many changes between Julia v0.6 and v0.7/v1.0 is is unlikely that the same package versions that you use on Julia v0.6 works on newer Julia versions, so you don't really gain anything from copying, since you need to "reinstall" new versions anyway.
I would also like to point out that the new package manager is much faster compared to the old one, so
pkg> add PackageA PackageB ...
to add all the packages you use should not take more than a minute.

Building Tools are missing in RStudio

First of all, I am working on a Mac. I am trying to install Blotter from GitHub. I found several descriptions of how to do that but my RStudio tells me that I am missing Building tools and gives me a link (https://www.cnet.com/how-to/install-command-line-developer-tools-in-os-x/) where it is described to do that. So far so good. I downloaded Xcode and the command line tools for Mac and installed those. Nothing changed even after restarting R. Then I found this https://cran.r-project.org/bin/macosx/tools/. I installed it and during that, it told me that I had to do the following
"This package will install clang 6.0.0 for OS X 10.11 (El Capitan) or higher with OpenMP support in /usr/local/clang6
In order to use this compiler you have to add /usr/local/clang6/bin to the PATH environment variable such as
export PATH=/usr/local/clang6/bin:$PATH"
So I changed the environmental variable path as follows http://blog.tonytsai.name/blog/2018-05-07-setting-path-variable-for-gs-command-in-rstudio/.
How I changed the PATH variable.
Again I restarted R but still, nothing changed. I still get the notice that the building tool is missing.
Somehow it seems to me that I installed everything correctly but R doesn't recognize the Programmes. Does anyone have an idea? I tried to search for settings to tell R that I installed the command line tool but couldn't really find anything helpful.
Ok, a bit of an update.
Best I can see it that Blotter is built and stored on R-Forge packages under a package called RStrategist
In R console type/cut & paste this.
install.packages('RStrategist',repos='http://R-Forge.r-project.org')
See R forR-Forge for more details. Once this has been installed run instead.
library(RStrategist)
Unfortunately, I am not willing to install this package and see if it works mainly because 1) don't need it nor know how to use it, 2) not sure how good packages are from R-forge, though it seems legit, but, this brings me back to point one.
So before i read the updated answer of Conrad Thiele i was trying around bit. Basically i deleted R, R Studio, Xcode and Command Line tools. Then i installed Xcode, Command Line tools, R and RStudio. Then i followed the notice on https://cran.r-project.org about the tools and installed both stated tools. As mentioned in the original question the Clang package tells you to change the Environmental Variable. And there was the mistake i believe. I originally simply pasted "PATH=/usr/local/clang6/bin:$PATH" into the the ".Renviron" file. With reading up online i noticed that "export PATH=/usr/local/clang6/bin:$PATH" is actually a Command for the Mac Terminal. After executing it, it sill didn't work but then i remembered that i still had the Path "PATH=/usr/local/clang6/bin:$PATH" in the the ".Renviron" file. Once i deleted that it worked. So i guess the key was that with changing the Environmental Variable correctly R found the connection with the right tool. Patients paid off.

R 3.0.0 crashes on startup

I just updated R from version 2.15.1 to version 3.0.0 on my MAC running 10.6.8 and now R crashes on startup.
I get the error:
Error in getLoadedDLLs() : there is no .Internal function 'getLoadedDLLs'
Error in checkConflicts(value) :
".isMethodsDispatchOn" is not a BUILTIN function
Any ideas on how to go about?
The most common cause of this is having a corrupted ".Rdata" file in your working directory. Using the Mac Finder.app you will not by default be able to see files that begin with a ".", so-called dotfiles. Those files can be "seen" if you execute a change to the plist controlling the behavior of Finder.app. Open a Terminal.app window and run this bit of code:
defaults write com.apple.Finder AppleShowAllFiles YES
Then /point/-/click/-/hold/ on Dock-Finder-icon, and choose "Relaunch"
If you to do so, you can then change it back with the obvious modfication to that procedure. I happen to like seeing the hidden files so that's the way I run my Mac all the time, but some people may feel it is too dangerous to expose the "hidden secrets" to their own bumbling.
Paul raises a good point: I run the following R function in the R console after updating:
update.packages(checkBuilt=TRUE, ask=FALSE)
I have a lot of installed packages and paging through the entire list has gotten too tiresome so I bypass the ask-messages. Sometimes you will get errors because there may be dependencies on r-forge or Omegahat packages or on packages that need to be compiled from source. These may need to be updated "by hand". And you may need more than one pass through such an effort. Take notes of which packages are missing and fill them in.
I had the same problem running RKWard on ubuntu 12.04.
Check your r-base-core, like Paul suggested, to make sure the version is also at the latest version. Mine didn't update automatically. I had a platform dependent version, but RKWard was calling the new version. To solve this problem, I simply marked r-base-core for removal and reinstalled the latest version or r-base-core. poof problem fixed, bippity boppity boo!
I suspect that your error is similar to mine because I had also JUST updated RKWard. Start at updating r-base-core or try to get all of the dependencies to match up the versions.
I hope that you can translate this into what to do on a MAC,
SU

Resources