http://uit.unt.edu/research

Data Science and Analytics

UITHelp Desk | Training | About Us | Publications | DSA Home

Please participate in the DSA Client Feedback Survey.

Back to the Do it yourself Introduction to R

Maintaining R is not difficult, it simply requires a few easy steps which will be covered here.

If you have your 'Rprofile.site' file setup to auto-load packages when R is started, then you will need to remove that file from the R directory prior to updating. If you do not, then the packages which you have specified to auto-load will never be updated. This is because R will not update a package if that package is loaded into the workspace. So, if you need to remove the 'Rprofile.site' file, then find the 'etc' folder in your R installation. Two examples of where it might be located are below where x.xx.x refers to the version number of the R installation you have (e.g. R-3.3.1).

C:\R\R-X.XX.X\etc

C:\Program Files\R\R-X.XX.X\etc

Once inside the 'etc' folder, right-click on the 'Rprofile.site' file and select "Cut". Now right-click on your desktop and select "Paste". You do not need to close the 'etc' window/folder.

I.) Installing NEW packages.

1.) Start R.

2.) Second, click on "Packages" at the top of the R console and then select "Set CRAN mirror...". Choose the mirror site you wish to use; it is recommended you choose a mirror site closest to your physical location -- this will enable quicker downloading. I generally select USA (TX 1), which is in Dallas, TX. You may also specify a default mirror site in your 'Rprofile.site' file as discussed previously. You can find a list of mirror site locations at CRAN by clicking here

 

3.) Next, click again on "Packages" in the R console and then select "Select repositories...". By default, CRAN and CRAN (extras) are selected; I generally also select R-Forge which contains packages being developed (often very recent updates to existing packages). Then click the OK button.

4.) Next, type the following line in the R console and hit the enter key:

x <- new.packages()

This line tells R you want to search for new packages at the repositories selected above and if any are available, they will be assigned to the object "x". The reason for doing this is so you can then (once it finishes; it can take a few minutes), type "x" and hit the return key to see the names of the new packages; thus allowing you to decide if you want all of them, some of them, or none of them.

5.) Next, if  you would like to install all of the new packages; then simply type the following line in the R console and hit the enter key:

install.packages(x)

If you would like to install only some of the packages, then you need to reference which ones you want using the number associated with the packages you want. For example, perhaps you only want the 1st package listed (in "x") and the 5th, 8th, 9th, and 10th -- then you would use the following script:

install.packages(x[c(1,5,8:10)])

Notice above, we used the brackets to refer to specific elements of "x" and we use the concatenate (or combine -- "c") to further specify multiple elements of "x". You could simply use quotation marks around the names of each package listed in "x" instead of the numbers (1, 5, and 8 through 10).

II.) Updating installed packages.

1.) Next, click again on "Packages" in the R console and then select "Update Packages...". Like with the new packages command, this can take a few minutes. Once done searching for updates, you will be presented with a list of updated package, you can select all of them, some of them, or none of them as you see fit.

Congratulations, you now have the most up to date packages.

Now close R and return to the desktop, cut the 'Rprofile.site' file from the desktop and paste it back into the 'etc' folder. Close the 'etc' window/folder and you're on your way.

To determine if a new version of R is available, simply point your favorite browser to http://cran.r-project.org/bin/windows/base/

 

Back to the Do it yourself Introduction to R

Please participate in the DSA Client Feedback Survey.

Contact Information

Jon Starkweather, PhD

Jonathan.Starkweather@unt.edu

940-565-4066

Richard Herrington, PhD

Richard.Herrington@unt.edu

940-565-2140

Last updated: 2018.11.06 by Jon Starkweather.

UITHelp Desk | Training | About Us | Publications | DSA Home