How to update rstudio

How to update rstudio

R-bloggers

R news and tutorials contributed by hundreds of R bloggers

How to install (and update!) R and RStudio

Posted on January 1, 2022 by R on R (for ecology) in R bloggers | 0 Comments

One of the first steps to learning R is to have it downloaded and installed on your computer. In this post I’ll show you how to do that and how to download and install RStudio—a key tool for using R, and how I do all my work and tutorials.

If you want to follow along with a video tutorial, you can click on the image below where you can watch the first lesson in my full course on the Basics of R (for ecologists).

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

For starters, R is a free open-source programming language used for organizing, analyzing, and visualizing data. Its versatility is highlighted by the large number of user-created packages that it comes with, which provide useful functions and guides that anyone can use (e.g., found on CRAN). So R is the programming language itself, and it comes with an environment or console that can read and execute your code. You could code in R without using RStudio, as you can see in the image below. That’s what the plain R console looks like; I just loaded up some data, viewed the first few rows, and renamed the columns.

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

By comparison, RStudio is a more versatile IDE, or Integrated Development Environment. Most people who use R also use RStudio because it provides a clean point-and-click dashboard of tools where you can type your code, view your figures, organize your data, variables, and files, as well as viewing the help window. In comparison to RStudio, the basic R IDE/console is extremely basic and doesn’t provide as many accessible tools as RStudio does.

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

If you are installing R and RStudio for the first time:

To download R, go here. Choose the download link that corresponds to your computer. I have a Mac, so I clicked that link.

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

You can download RStudio here, and you want to choose “RStudio Desktop”.

The important thing when installing R and RStudio is that you need to install R before you install RStudio. If you do it in the reverse order, you will likely run into errors. All you’ll need to do is open the files you downloaded for R and RStudio, and the installation process should begin on its own.

For Mac users, there’s also something called XQuartz, which you might not need for basic coding in R, but which might be helpful down the line for running certain packages. You can download XQuartz here. Similarly, if you just open the downloaded file, XQuartz should install on its own.

If you want to update R and RStudio:

There are a few ways you can check your version of R and see whether or not it needs to be updated. One way is to run the actual R program. There, you can go to the “R” menu and click “Check for R Updates” (see image below). If you do that, R will tell you the current version you’re on, and whether or not there is a more updated version that you can download (circled in blue).

Alternatively, if you’re in RStudio, you can type and run “sessionInfo()” in the R Console. The first line that the console returns is the version of R that you’re using. You can then download and install the latest version of R here for Mac, and here for Windows.

If you’re using a Windows computer, you may need to uninstall R to update it. You can find a quick guide for that here. Another great option for Windows users is to use a package called installr (unfortunately only available for Windows, @Mac users). All you need to do is install “installr”, load up the library, and run the code “updateR()”. This function will check for newer versions and will guide you through the update process.

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

If you want to update to the latest version of RStudio, hover over “Help” on the top menu bar of your Mac, and click “Check for Updates”. Then, quit the RStudio program, go to the RStudio website, and download and install the latest version. How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudioNow you should have the latest versions of R and RStudio on your computer. I hope this tutorial was helpful!

If you liked this post and want to learn more, then check out my online course on the complete basics of R for ecology:

Also be sure to check out R-bloggers for other great tutorials on learning R

A step by step (screenshots) tutorial for upgrading R on Windows

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

If you are running R on Windows you can easily upgrade to the latest version of R using the installr package. Simply run the following code:

Running “updateR()” will detect if there is a new R version available, and if so it will download+install it (etc.). just press “next”, “OK”, and “Yes” on everything…

A GUI interface to updating R on Windows

Starting from installr version 0.15.0, the upgradingprocess can be done with a click-on-menus GUI interface. Here is how to use it.

Step 1: load installr

Step 2: pick “update R” from the new “installr” menu

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

Step 3: installr will check and detect that there is a new version of R for you – click “OK”

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

Step 4: if you wish to check the NEWS of the new R version – click “Yes” and a browser window will open up with this information

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

Step 5: if you want to download and install the latest R version, press “Yes”

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

Step 6: wait for R to download

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

Step 7: press “next” in R’s installation wizard

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

Step 8: wait R finishes to get installed

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

Step 9: Press “Yes” to copy your packages to the new R installation (press No, if you intend to use the “global R library folder” strategy)

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

Step 10: to keep package in your old R folder, press “Yes” (this is safest)

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

Step 11: wait while the packages get copied

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

Step 12: you can also have Rprofile.site be copied automatically to the new location

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

Step 13: you may press “Yes” to get update packages in the new R installation

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

Step 14: if you have a firewall, R may ask to get access to the internet

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

Step 15: while the packages are updated, you will need to wait. A hidden Rscript process will run in the background and update the packages

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

Step 16: once it is all done, you will be offered to quit R (sure, why not)

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

Feedback

I try to keep the installr package updated and useful, so if you have any suggestions or remarks on the package – you are invited to leave a comment below, or report an issue on github.

How to Keep Your R Packages Up to Date

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

A user who recently completed my Getting Started with R course sent me an email to ask a common question for those starting out with R:

How do you keep your R software up to date? As far as I know, there are no automatic updates for R, RStudio and packages. And as updates are quite frequent, it is quite a hassle to check every few weeks (or even days) if there are new versions available.

This is the kind of thing that experienced R users have often internalized to the point that they often forget to articulate the steps to newcomers. It’s perhaps not surprising: unlike other pieces of software, the process of updating RStudio, R, and R packages, and it is not straightforward. So, let’s take each of these in turn.

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudio

Ready to start learning R?

Sign up for the free Getting Started with R

How to Update RStudio

You can update RStudio by visiting the download page on the RStudio website. Find the latest version for your operating system, download it, install it, and it will overwrite your current version.

Some people enjoy running the RStudio “dailies”, which are daily compilations of the latest code for RStudio. While a big warning says they may not be stable, they show what the RStudio team is working on. People are currently very excited to see rainbow parentheses coming in a future release of RStudio (in addition to being pretty, this makes it much easier to match open and close parentheses).

How to Update R

The easiest way to update R is to simply download the newest version. Install that, and it will overwrite your current version. There are also packages to do the updating: updateR for Mac, and installr for Windows. No matter which method you use, for most people, the challenge comes not in updating R, but in what comes as a result.

How to Update R Packages

When you update R, the biggest challenge is that your personal library of packages no longer works. When I upgraded to R 4.0, all of the packages I had downloaded while using version 3.61 were no longer recognized. There are multiple approaches to dealing with this:

Some people suggest copying your old personal library to a new location and ensuring that the new version of R recognizes it (others take the opposite view, saying that a new version of R is a good time to start with a clean slate and only install packages that you need moving forward).

Indeed, others, including Jeff Newmiller, suggest this approach is problematic. As Jeff wrote me via email:

[Copying your library to a new location] is NOT a safe thing to do, since the whole reason R sets up a new library is to avoid mixing incompatible packages. Following the copy with a rebuild only fixes packages that are in your repository list for the new version of R… any packages that have already failed compatibility testing will remain broken, and they are the ones you are most at risk from.

Others point you to the updateR and installr packages, which each have functions to copy your existing packages to your new version of R.

Colin Gillespie and Robin Lovelace have a chapter on keeping everything up to date in their book Efficient R Programming. And Chapter 8 of Jenny Bryan and Jim Hester’s What They Forgot to Teach You About R has something similar.

What Do I Do?

I may have strayed from the original question a bit because the user was asking how I handle updating my tools. Here’s my approach:

I upgrade RStudio whenever I hear about something new and exciting in the most recent version (you better believe I’m excited about rainbow parentheses).

I update R several weeks after a new version is released. I don’t like to be a guinea pig in case there are issues so I let others find them and update once they’re fixed.

I update packages quite often (probably every few days). Mostly this happens because I am asked if I want to do so when using the install_github() function from the remotes package to install a package that is not on CRAN but is on GitHub.

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudioThe prompt to update my R packages

If I don’t update packages through this function, I use the packages tab in RStudio. I click the update button, which shows me which packages need updating, and then update them all.

How to update rstudio. Смотреть фото How to update rstudio. Смотреть картинку How to update rstudio. Картинка про How to update rstudio. Фото How to update rstudioHow I update packages using RStudio

The Downsides of Updating

Updating RStudio, R, and your packages is, for the most part, painless once you know what to do. But there are some downsides to keep in mind. In addition to having to jump through some hoops to use your old packages on a new install of R, updating R packages can also mess up some of your old code. To be clear, this doesn’t happen often as developers try their hardest to avoid breaking changes. But, at times, the development of improved packages leads to versions of code that rely on older versions of packages to break.

Fortunately, there is a solution for this: the renv package. Although I haven’t used this package myself, it looks quite helpful. It essentially keeps copies of your R packages as they existed when you wrote your original code. So, if you were using dplyr 0.8.5 to write code for analysis in March 2020, you don’t have to worry that changes made to that package in the future will make your code unusable today if you’ve updated to dplyr 1.0.

Conclusion

Keeping RStudio, R, and your packages up to date can seem like a pain, but once you know how to do it, it’s not that challenging. With packages in particular, the benefits of updating are significant: you get access to the latest functions to make your life easier. For example, many have found the addition of pivoting functions in a recent version of the tidyr package has been a drastic improvement in my R experience.

I thought that my glee about pivot_longer()- and pivot_wider()-ing successfully without googling an example would fade, but nope.

Work with R long enough and eventually you’ll find that you’ve become an experienced user with always up to date packages. Knowing that you’ve got the most up-to-date tools means you can put your focus where it should be: on using R to do amazing work!

Updating R from R (on Windows) – using the package

Upgrading R on Windows is not easy. While the R FAQ offer guidelines, some users may prefer to simply run a command in order to upgrade their R to the latest version. That is what the new package is all about.

The package offers a set of R functions for the installation and updating of software (currently, only on Windows OS), with a special focus on R itself. To update R, you can simply run the following code:

Running this function will perform the following steps:

Check what is the latest R version. If the current installed R version is up-to-date, the function ends (and returns FALSE)

If a newer version of R is available, you will be asked if to review the NEWS of the latest R version – in order to decide if to install the
newest R or not.

If you wish it – the function will download and install the latest R version. (you will need to press the «next» buttons on your own)

Once the installation is done, you should press «any-key», and the function will proceed with copying all of your packages from your old (well, current) R installation, into your newer R installation.

You can then erase all of the packages in your old R installation.

After your packages are moved (and the old ones possibly erased), you will get the option to update all of your packages in the new version of R.

Lastely – you can open the new Rgui and close the current session of your old R. (This is a bit buggy in version 0.8, but has been fixed in version 0.8.1)

If you know you wish to upgrade R, and you want the packages moved (not copied, MOVED), you can simply run:

Since the various steps are broken into individual functions, you can also pick and choose what to run using the relevant function:

If you like using the global library system, you can run the following in the old R:

And then run the following in the new version of R:

The package also offers functions for installing various other software on Windows. These functions include: install.pandoc (which was mentioned on this blog recently), install.git, install.Rtools, install.MikTeX, install.RStudio, and a general install.URL and install.packages.zip functions. You can see these further explained in the package’s Reference manual.

Feature requests, bug reports – and your help in improving the package

You can see the latest version of installr on github, where you can also submit bug reports (you may also just leave a comment in this post). Since this is my first R package, I might have (e.g: probably have) missed something here or there. So any comment on how to improve my code/documentation/R-fu, will be most welcomed (here or on github).

If this type of coding is fun/easy for you, you can help me improve this package on github. Cool new features I think may be added (by me or others) are:

Thanks

Final note, I would like to thank the many people who have developed WONDERFUL tools for making R package development possible (and even somewhat fast), on Windows. These include Prof. Brian Ripley and Duncan Murdoch for Rtools, also Uwe Ligges for his work on CRAN, Hadley Wickham for devtools (in general, and for its documentation), Yihui Xie for roxygen2, JJ and others in the RStudio team for RStudio, the people behind git and github, and more. There are probably more things I can thank these people for, and many more people I should thank, but I can’t figure who you are probably (feel free to e-mail me, I appreciate you work even if it is not clear to me your are behind it).

Happy Git and GitHub for the useR

Install a pre-compiled binary of R for your OS from here:
https://cloud.r-project.org
Already have R installed? Hold on: This is a great time to make sure your R installation is current. Check your current version like so:

Install RStudio Desktop.
Already have RStudio? Hold on: This is a great time to upgrade to the latest Preview version. Download it here:
https://www.rstudio.com/products/rstudio/download/preview/

Update your R packages:

5.1 How to think about upgrading R and RStudio

Get current, people. You don’t want to adopt new things on day one. But at some point, running old versions of software adds unnecessary difficulty.

In live workshops, there is a limit to how much we can help with ancient versions of R or RStudio. Also, frankly, there is a limit to our motivation. By definition, these problems are going away and we’d rather focus on edge cases with current versions, which affect lots of people.

Is your R version “old”? R had a major version change in April 2020, with the release of 4.0.0. It is a good idea to be on the current major version, meaning 4.something at this point, especially if you want to get the most out of a workshop.

Each major version is followed by several years of smaller releases (minor and patch releases). You can be more relaxed about upgrading minor versions, but you still want to stay reasonably current. As the 4.something series unfolds, I advise that you never fall more than 1 minor version behind.

Concrete example: let’s say the released version of R is 4.7.1, which is totally fictional and well beyond the current version of R at the time of writing. It’s probably OK if you are still on 4.6.whatever, which is one minor version behind and is called “r-oldrel”. Being one minor version behind usually doesn’t cause trouble. Once you are 2 minor versions behind (4.5.whatever or earlier in this example), you will start to suffer. In particular, you can no longer install pre-built binary add-on packages from CRAN.

Is your RStudio “old”? Unless you have a specific reason to prefer the released version, try the Preview. RStudio is fairly conservative with official releases, so the Preview version is used by many people for their daily work. This allows you to enjoy the latest goodies much sooner. The Preview version updates much more frequently (and in smaller increments) than the released version. This is something you might update once every month or so.

Источники информации:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *