{"id":870,"date":"2015-08-12T13:21:04","date_gmt":"2015-08-12T20:21:04","guid":{"rendered":"http:\/\/homepages.uc.edu\/~yaozo\/wordpress\/?p=870"},"modified":"2015-08-12T13:21:04","modified_gmt":"2015-08-12T20:21:04","slug":"updating-r-from-r-on-windows-using-the-installr-package","status":"publish","type":"post","link":"https:\/\/zhuoyao.net\/index.php\/2015\/08\/12\/updating-r-from-r-on-windows-using-the-installr-package\/","title":{"rendered":"Updating R from R (on Windows) \u2013 using the {installr} package"},"content":{"rendered":"<p>Upgrading R on Windows is not easy. While the <a href=\"http:\/\/cran.r-project.org\/bin\/windows\/base\/rw-FAQ.html#What_0027s-the-best-way-to-upgrade_003f\">R FAQ offer guidelines<\/a>, some users may prefer to simply run a command in order to upgrade their R to the latest version. That is what the <em>new <\/em><a href=\"http:\/\/cran.r-project.org\/web\/packages\/installr\/\">{installr}<\/a> package is all about.<\/p>\n<p>The {<a href=\"http:\/\/cran.r-project.org\/web\/packages\/installr\/\">installr<\/a>} 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:<\/p>\n<div class=\"wp_codebox\">\n<table>\n<tbody>\n<tr id=\"p609321\">\n<td id=\"p60932code1\" class=\"code\">\n<pre class=\"rsplus\"># installing\/loading the package:\nif(!require(installr)) {\ninstall.packages(\"installr\"); require(installr)} #load \/ install+load installr\n\u00a0\n# using the package:\nupdateR() # this will start the updating process of your R installation.  It will check for newer versions, and if one is available, will guide you through the decisions you'd need to make.<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Running this function will perform the following steps:<\/p>\n<ul>\n<li><strong>Check what is the latest R version<\/strong>. If the current installed R version is up-to-date, the function ends (and returns FALSE)<\/li>\n<li>If a newer version of R is available, you will be asked if to <strong>review the NEWS<\/strong> of the latest R version \u2013 in order to decide if to install the<br \/>\nnewest R or not.<\/li>\n<li>If you wish it \u2013 the function will <strong>download and install<\/strong> the latest R version. (you will need to press the &#8220;next&#8221; buttons on your own)<\/li>\n<li>Once the installation is done, you should press &#8220;any-key&#8221;, and the function will proceed with <strong>copying all of your packages<\/strong> from your old (well, current) R installation, into your newer R installation.<\/li>\n<li>You can then <strong>erase <\/strong>all of the <strong>packages <\/strong>in your <strong>old R <\/strong>installation.<\/li>\n<li>After your packages are moved (and the old ones possibly erased), you will get the option to <strong>update <\/strong>all of your <strong>packages <\/strong>in the new version of R.<\/li>\n<li>Lastely \u2013 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)<\/li>\n<\/ul>\n<p>If you know you wish to upgrade R, and you want the packages moved (not copied, MOVED), you can simply run:<\/p>\n<div class=\"wp_codebox\">\n<table>\n<tbody>\n<tr id=\"p609322\">\n<td id=\"p60932code2\" class=\"code\">\n<pre class=\"rsplus\"># installing\/loading the package:\nif(!require(installr)) { install.packages(\"installr\"); require(installr)} #load \/ install+load installr\n\u00a0\nupdateR(F, T, T, F, T, F, T) # install, move, update.package, quit R.<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Since the various steps are broken into individual functions, you can also pick and choose what to run using the relevant function:<\/p>\n<div class=\"wp_codebox\">\n<table>\n<tbody>\n<tr id=\"p609323\">\n<td id=\"p60932code3\" class=\"code\">\n<pre class=\"rsplus\"># installing\/loading the package:\nif(!require(installr)) { install.packages(\"installr\"); require(installr)} #load \/ install+load installr\n\u00a0\n# step by step functions:\ncheck.for.updates.R() # tells you if there is a new version of R or not.\ninstall.R() # download and run the latest R installer\ncopy.packages.between.libraries() # copy your packages to the newest R installation from the one version before it (if ask=T, it will ask you between which two versions to perform the copying)<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>If you like using <a href=\"http:\/\/www.r-statistics.com\/2010\/04\/changing-your-r-upgrading-strategy-and-the-r-code-to-do-it-on-windows\/\">the global library system<\/a>, you can run the following in the old R:<\/p>\n<div class=\"wp_codebox\">\n<table>\n<tbody>\n<tr id=\"p609324\">\n<td id=\"p60932code4\" class=\"code\">\n<pre class=\"rsplus\"># installing\/loading the package:\nif(!require(installr)) { install.packages(\"installr\"); require(installr)} #load \/ install+load installr\n\u00a0\nupdateR(F, T, F, F, F, F, T) # only install R (if there is a newer version), and quits it.<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>And then run the following in the new version of R:<\/p>\n<div class=\"wp_codebox\">\n<table>\n<tbody>\n<tr id=\"p609325\">\n<td id=\"p60932code5\" class=\"code\">\n<pre class=\"rsplus\">source(\"http:\/\/www.r-statistics.com\/wp-content\/uploads\/2010\/04\/upgrading-R-on-windows.r.txt\")\nNew.R.RunMe()<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>The {<a href=\"http:\/\/cran.r-project.org\/web\/packages\/installr\/\">installr<\/a>} package also offers functions for installing various other software on Windows. These functions include: install.pandoc (which was <a href=\"http:\/\/www.r-statistics.com\/2013\/02\/installing-pandoc-from-r-on-windows\/\">mentioned on this blog<\/a> 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 <a href=\"http:\/\/cran.r-project.org\/web\/packages\/installr\/installr.pdf\">the package\u2019s Reference manual<\/a>.<\/p>\n<h3>Feature requests, bug reports \u2013 and your help in improving the package<\/h3>\n<p>You can see the latest version of <a href=\"https:\/\/github.com\/talgalili\/installr\/\">installr on github<\/a>, where you can also<a href=\"https:\/\/github.com\/talgalili\/installr\/issues\">submit bug reports<\/a> (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).<\/p>\n<p>If this type of coding is fun\/easy for you, you can help me improve <a href=\"https:\/\/github.com\/talgalili\/installr\/\">this package on github<\/a>. Cool new features I think may be added (by me or others) are:<\/p>\n<ul>\n<li>Add an uninstall.R function \u2013 to remove the old R version.<\/li>\n<li>Add more support for upgrading R for people who uses <a href=\"http:\/\/www.r-statistics.com\/2011\/04\/how-to-upgrade-r-on-windows-7\/\">a global library<\/a>for their packages.<\/li>\n<li>Add support for Linux and Mac! This one I am less likely to do on my own \u2013 and would love to see someone else extend my code to other operation systems.<\/li>\n<li>GUI \u2013 add a menu based option for running updateR. Something like help-&gt;\u201dcheck for updates\u201d would be great. (p.s: this idea came from Yihui Xie)<\/li>\n<li>add even more install.software functions. If you have functions for which you\u2019d like to be able to easily install them \u2013 just let me know and it could be included in future releases.<\/li>\n<\/ul>\n<h3>Thanks<\/h3>\n<p>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 <a href=\"http:\/\/cran.r-project.org\/bin\/windows\/Rtools\/\">Rtools<\/a>, also <a href=\"http:\/\/www.statistik.tu-dortmund.de\/ligges.html\">Uwe Ligges<\/a> for his work on CRAN,<a href=\"http:\/\/had.co.nz\/\">Hadley Wickham<\/a> for <a href=\"https:\/\/github.com\/hadley\/devtools\">devtools<\/a> (in general, and for its <a href=\"https:\/\/github.com\/hadley\/devtools\/wiki\/Package-basics\">documentation<\/a>),<a href=\"http:\/\/yihui.name\/en\/\">Yihui Xie<\/a> for <a href=\"https:\/\/github.com\/yihui\/roxygen2\">roxygen2<\/a>, <a href=\"http:\/\/www.rstudio.com\/about\/\">JJ and others<\/a> in the RStudio team for <a href=\"http:\/\/www.rstudio.com\/\">RStudio<\/a>, 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\u2019t 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).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-870","post","type-post","status-publish","format-standard","hentry","category-r"],"_links":{"self":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts\/870","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/comments?post=870"}],"version-history":[{"count":0,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts\/870\/revisions"}],"wp:attachment":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/media?parent=870"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/categories?post=870"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/tags?post=870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}