[R-SIG-Mac] Corrupt R installation

Simon Urbanek @|mon@urb@nek @end|ng |rom R-project@org
Thu Jun 10 00:26:45 CEST 2021


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



More information about the R-SIG-Mac mailing list