[R-SIG-Mac] Corrupt R installation

peter dalgaard pd@|gd @end|ng |rom gm@||@com
Thu Jun 10 08:33:14 CEST 2021


Yep. (In the first form, you likely want a stoplist for base and recommended packages.)

You can also base it on a listing of the library directory. This has the advantage that you can fairly easily twiddle it to look at older versions after the upgrade.

> .libPaths()
[1] "/Library/Frameworks/R.framework/Versions/4.0/Resources/library"
> list.files("/Library/Frameworks/R.framework/Versions")
[1] "3.0"     "3.1"     "3.2"     "3.3"     "3.4"     "3.5"     "3.6"    
[8] "4.0"     "Current"
> list.files("/Library/Frameworks/R.framework/Versions/3.6/Resources/library")
  [1] "assertthat"            "backports"             "base"                 
  [4] "base64enc"             "BH"                    "bitops"               
  [7] "boot"                  "caTools"               "chron"                
 ...
> setdiff(list.files("/Library/Frameworks/R.framework/Versions/3.6/Resources/library"),rownames(installed.packages()))
[1] "caTools"      "dplyr"        "plogr"        "translations"

(Notice that "translations" is not a package, so  a red herring in this context)

-pd

> On 10 Jun 2021, at 00:26 , Simon Urbanek <simon.urbanek using r-project.org> wrote:
> 
> 
> Um, this is actually a lot easier purely with R - if you want to keep track of your favorite packages it is as simple as
> 
> pkgs = rownames(installed.packages())
> writeLines(pkgs, "packages.txt")
> 
> and oyu have a list of all packages that you can edit if desired. if you ever want to re-install then simply
> 
> pkgs = readLines("packages.txt")
> install.packages(pkgs)
> 
> and if you only want to install missing it's simply
> 
> missing.pkgs = pkgs[!pkgs %in% rownames(installed.packages())]
> install.packages(missing.pkgs)
> 
> All trivially done in R. It is always beyond me why people come up with incredibly convoluted solutions to simple things ..
> 
> Cheers,
> Simon
> 
> 
> 
>> On 9/06/2021, at 8:55 PM, Dr Eberhard Lisse <nospam using lisse.NA> wrote:
>> 
>> On 08/06/2021 22:46, moleps islon wrote:
>> [...]
>>> I have no idea why, but my R installation (Mac OS X - Big Sur)
>>> automatically updates causing havoc with my libraries each time.  My
>>> Mac is under administration from the university and their software
>>> center, but they claim it is not their fault - but I still suspect
>>> them for causing all the trouble.
>> [...]
>> 
>> Sounds like Homebrew to me.  If so, or anyway, create a file (before
>> updating) which contains something like
>> 
>> 	 #!/usr/bin/env Rscript --vanilla
>> 	 #
>> 	 # set the Mirror
>> 	 #
>> 	 local({
>> 		r <- getOption("repos")
>> 		 r["CRAN"] <- "https://cloud.r-project.org/"
>> 		options(repos = r)
>> 	 })
>> 	 install.packages(c(
>> 		  "lubridate",
>> 		  "tidyverse"
>> 	 ), dependencies = TRUE)
>> 
>> 
>> or similar and run it if the additional libraries disappear.
>> 
>> You can fill this with something like
>> 
>> 	 grep -h library *R \
>> 	 |awk -F 'library' '{print $2}' \
>> 	 |sed 's/(//g;s/)//g' \
>> 	 |sort -u \
>> 	 |awk '{print "\"" $1 "\","}'
>> 	 |sed '$ s/,$//'
>> 
>> or in a few lines of the language of your choice generate the whole
>> script. And of course refine to your liking with something like
>> 
>> 	 find ~/R -name '*.R' -exec grep -h library {} ';' \
>> 	 ...
>> 
>> greetings, el
>> 
>> -- 
>> To email me replace 'nospam' with 'el'
>> 
>> _______________________________________________
>> R-SIG-Mac mailing list
>> R-SIG-Mac using r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
> 
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd.mes using cbs.dk  Priv: PDalgd using gmail.com



More information about the R-SIG-Mac mailing list