Migrating R code from one machine to another

As the subject says I am about to migrate all my work to a new machine and I would like to know if there are any best practices for doing so. Like can I get a list of all packages on my machine with its versions and use that to install it on my new machine.

Thank you.

You can make a table with installed.packages():

ip <- installed.packages()
#            Package      LibPath                                       Version Priority
# acepack    "acepack"    "C:/Users/nwerth/Documents/R/win-library/3.6" "1.4.1" NA      
# acs        "acs"        "C:/Users/nwerth/Documents/R/win-library/3.6" "2.1.4" NA      
# askpass    "askpass"    "C:/Users/nwerth/Documents/R/win-library/3.6" "1.1"   NA      
# assertthat "assertthat" "C:/Users/nwerth/Documents/R/win-library/3.6" "0.2.1" NA      
# backports  "backports"  "C:/Users/nwerth/Documents/R/win-library/3.6" "1.1.4" NA      
# base64enc  "base64enc"  "C:/Users/nwerth/Documents/R/win-library/3.6" "0.1-3" NA      
#            Depends                              Imports                              LinkingTo Suggests        
# acepack    NA                                   NA                                   NA        "testthat"      
# acs        "R (>= 2.10), stringr, methods, XML" "graphics, stats, plyr, utils, httr" NA        ""              
# askpass    NA                                   "sys (>= 2.1)"                       NA        "testthat"      
# assertthat NA                                   "tools"                              NA        "testthat, covr"
# backports  "R (>= 3.0.0)"                       "utils"                              NA        NA              
# base64enc  "R (>= 2.9.0)"                       NA                                   NA        NA              
#            Enhances License              License_is_FOSS License_restricts_use OS_type MD5sum NeedsCompilation
# acepack    NA       "MIT + file LICENSE" NA              NA                    NA      NA     "yes"           
# acs        NA       "GPL-3"              NA              NA                    NA      NA     "no"            
# askpass    NA       "MIT + file LICENSE" NA              NA                    NA      NA     "yes"           
# assertthat NA       "GPL-3"              NA              NA                    NA      NA     "no"            
# backports  NA       "GPL-2"              NA              NA                    NA      NA     "yes"           
# base64enc  "png"    "GPL-2 | GPL-3"      NA              NA                    NA      NA     "yes"           
#            Built  
# acepack    "3.6.0"
# acs        "3.6.0"
# askpass    "3.6.0"
# assertthat "3.6.0"
# backports  "3.6.0"
# base64enc  "3.6.0"

Just keep the names from the "Package" column to use when installing again. If you want to freeze your package versions, then see if the renv package meets your needs. I haven't used it, but it sounds like it might help.

Thank you. I get this will get me the list of all packages I want to install on my new machine. But do I have a way to install separate them by CRAN and non CRAN.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.