Detach several packages at once

后端 未结 4 2029
不思量自难忘°
不思量自难忘° 2020-12-28 21:11

Inspired by this answer I am looking for a way to detach several packages at once.

When I load say Hmisc,

# install.packages(\"Hmisc\", dependencies          


        
4条回答
  •  囚心锁ツ
    2020-12-28 21:56

    To answer my own question to Hong's answer:

    detlist<-c('Hmisc','survival','splines')
    
    lapply(detlist, function(k) detach( paste('package:', k, sep='', collapse=''), unload=TRUE, char=TRUE))
    

    Works just fine. The sorting function at the top of base::detach is a bit wonky, but using character.only=TRUE got me thru just fine.

提交回复
热议问题