[?]

가끔씩 패키지들을 너무많이 다운받으면 

패키지간에 충돌을 일으켜서 실행이 안되곤 합니다.

detach를 활용해서 패키지를 하나씩 언로드 할수도 있는것 같지만

어떤 패키지에서 문제가 일어나는지 모를 때는 한번 밀어버리고 싶은데

R-Blogger에서 좋은 스크립트를 발견!


[코드]


# create a list of all installed packages

ip <- as.data.frame(installed.packages())

head(ip)

# if you use MRO, make sure that no packages in this library will be removed

ip <- subset(ip, !grepl("MRO", ip$LibPath))

# we don't want to remove base or recommended packages either\

ip <- ip[!(ip[,"Priority"] %in% c("base", "recommended")),]

# determine the library where the packages are installed

path.lib <- unique(ip$LibPath)

# create a vector with all the names of the packages you want to remove

pkgs.to.remove <- ip[,1]

head(pkgs.to.remove)

# remove the packages

sapply(pkgs.to.remove, remove.packages, lib = path.lib)



출처 :  R-Blogger

https://www.r-bloggers.com/how-to-remove-all-user-installed-packages-in-r/

반응형
Posted by JoeSung
,