Function to list all imported packages in a project

This commit is contained in:
2022-06-16 13:09:14 +01:00
parent 903f5cf365
commit 141ca866ca
3 changed files with 34 additions and 0 deletions

View File

@@ -3,3 +3,4 @@
export(fetch_available_archives) export(fetch_available_archives)
export(fetch_available_packages) export(fetch_available_packages)
export(list_depends) export(list_depends)
export(list_imports)

17
R/list_imports.R Normal file
View File

@@ -0,0 +1,17 @@
#' Find all the packages the current project directly includes and their
#' versions.
#'
#' @return A data frame with the directly required packages
#' @export
list_imports <- function() {
packages <- sort(unique(renv::dependencies(progress = FALSE)$Package))
all_packages <- installed.packages()
all_packages <- as.data.frame(all_packages)
all_packages <- all_packages[all_packages$Package %in% packages,]
packages <- data.frame(
package = all_packages$Package,
version = all_packages$Version
)
return(packages)
}

16
man/list_imports.Rd Normal file
View File

@@ -0,0 +1,16 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/list_imports.R
\name{list_imports}
\alias{list_imports}
\title{Find all the packages the current project directly includes and their
versions.}
\usage{
list_imports()
}
\value{
A data frame with the directly required packages
}
\description{
Find all the packages the current project directly includes and their
versions.
}