Programming/R

R 패키지 dependency 확인

neopin 2022. 1. 15. 22:44

 

getPackages <- function(packs){  
  packages <- unlist(    
    # Find (recursively) dependencies or reverse dependencies of packages.    
    tools::package_dependencies(packs, available.packages(),
                                which=c("Depends", "Imports"), recursive=TRUE)    
  )
  packages <- union(packs, packages)  
  return(packages)
}

packages <- getPackages(c("dplyr", "ggplot2"))

print(packages)