패키지 등이 서로 충돌을 일으키는데 무엇이 문제인지 모르겠거나 전체적으로 삭제하고 싶은 경우 사용할 수 있는 스크립트.

System library를 제외하고 user library만을 삭제해준다.

아래 코드를 복사 후 붙여넣기.


# 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)


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

+ Recent posts