Can I install R from within RStudio? - r

R version 3 is released as announced at R bloggers. I am using RStudio and would like to know if it is possible to install the new version from within RStudio. Any precautions for may installed packages, functions and data?

RStudio has built-in support for updating packages, but not for updating R itself.
If you're using Windows, the installr package can be used to update R (as was mentioned on R-bloggers). Otherwise your update will need to be more manual.

Related

R not loading packages on some MAC versions

I am using the regular R console on a MAC Air with Monterrey as the OS and I'm still having issues loading packages. It is iffy, as to whether a package is loaded and ready to use. Sometimes packages will load and sometimes not. Also, it would not call up data sets that as a default are included in the R packages I'm trying to use. the weird thing is it would recognize the example dataset that is included because when I first tied to call them up, it would let me autocomplete the name. Then it stopped doing that. Then it started telling me that the file doesn't exist. I know I haven't used R in a while but this just seems buggy! any help would be appreciated.
The R version that I have installed is : R version 4.2.0 (2022-04-22) -- "Vigorous Calisthenics" and it was installed just last week.
It seems R was not properly installed on your machine.
Several persons reported that using the package manager in RStudio actually did the trick of updating the packages.

Use different versions of packages in R

I am reading a book published in 2019 that uses a package (JWileymisc) that has been updated and some of the functions are deprecated, so I am spending too much time trying to update the examples. The authors use checkpoint package but I have not been able to make it work in my laptop (I don't have full rights and could not install R version 3.5.1).
I installed the older version of the package it is used in the book but I still get error message saying the functions could not be found. Is there a way around it without checkpoint and this old version of R? Or is it possible to call a function from an old version of a package? I am using Windows, by the way.
Thanks! :)

Can renv be used to create a virtual environment with a specific version of R?

I recently installed R 4.0, after previously using relying R 3.6.3. To manage R repositories, I use Rstudio (currently 1.2.5042 on a Windows 10 machine). After upgrading to R 4.0, I opened a project from a few months ago, and realized that Rstudio is now, by default, using the newer version of R (and it's library folder). When running renv::restore(), renv attempts to re-install all libraries in the .lock file for the newer version of R, and I don't see any way to specify that I want to keep using R 3.6.3 and it's associated library.
Coming from a python background, I had assumed that renv would create a virtual environment that isolates both the interpreter and the libraries that the project uses (similar to how anaconda environments are created). However, after looking through the documentation and doing a few searches, I have found no reference to isolating a particular version of R. I have, however, found that Rstudio defaults to using the latest version of R, which is not necessarily the behaviour that I want.
I have tried using anaconda to manage an R environment. However, Anaconda relies on its own smaller repository of R packages, and many of the libraries I need are from researchers that house their code on GitHub.
Is there a way to create an R environment in which I can isolate both the R libraries and the version of R itself? Or, perhaps there is something I am missing about how environments with R/Rstudio are intended to be used?
You are correct that renv only manages the installed R packages, and not the R interpreter itself.
Depending on how you're using RStudio, you can still "fake" this by setting the RSTUDIO_WHICH_R environment variable. For example:
export RSTUDIO_WHICH_R=/path/to/R
rstudio
would tell RStudio to "bind" to the version of R specified by the RSTUDIO_WHICH_R environment variable.
For what it's worth, the ability to bind projects to a specific version of R is a feature of the professional editions of RStudio; however, it's not available in the open-source version. See here for more details.

How to easily switch R versions on rstudio ubuntu based?

I need to install a package that gives the following error so I am looking for a solution to that. The first approach is looking at ways to chose the right R version.
Should I spend some more time on this or there are other approaches to overcome this issue?
For this package you need R (≥ 3.5.0), so R 3.4.4 is not sufficient for standard installation.
Check on the cran website of the package for further information.
For upgrading R on ubuntu check here (old link!)
Edit: wibeasley mentioned a new link in the commentary for updating R 3.5.0 on Ubuntu.
Check the new link

R package listed on CRAN but not in available package

I want to install a package that is listed in https://cran.r-project.org/web/packages/available_packages_by_name.html as available in CRAN, but when I check in R the install packages menu or the available.packages() command, I can't see the package there.
Do I need to do something different to install those packages? Why aren't those packages available?
The packages I'm interested on are WikipediR ( https://cran.r-project.org/web/packages/WikipediR/index.html ), WikidataR and WikipediaR.
If it matters, I'm using R 2.15.0 in Windows XP.
See the documentation for ?available.packages...
By default, the return value includes only packages whose version and
OS requirements are met by the running version of R, and only gives
information on the latest versions of packages.
In other words... your R 2.15 is likely too old for the package you are looking to download.
You can try to download the package source manually add the package to the package library usually found somewhere like "win-library/2.15/" but like Cory mentioned it is likely that the older version of R does not support the package build.
The advice given so far is a bit incomplete although I do agree you need to update your R version if you want to use these packages. Looks like they don't need compilation so you might have been able to either install from a local copy or drop R code in, but critically they depend on httr which requires R 3.0.0 or above. They were released only relatively recently, so there will be no Windows binaries from back in 2012. (Your copy of R is from 30-Mar-2012.) Look in the DESCRIPTION file which is presented in a nice web format at the CRAN/package listing:
https://cran.r-project.org/web/packages/WikidataR/index.html
Imports: httr, jsonlite, WikipediR
Suggests: testthat, knitr, pageviews
# only one version of these two
https://cran.r-project.org/src/contrib/Archive/WikidataR/WikidataR_1.0.0.tar.gz
https://cran.r-project.org/src/contrib/Archive/WikipediaR/WikipediaR_1.0.tar.gz
# pick one of these
https://cran.r-project.org/src/contrib/Archive/WikipediR/

Resources