dataset_description,
Arguments
- df
Name of data.frame or tibble object
- title
The text you want in the
@title
part of the documentation- description
The text you want in the
@description
part of the dataset documentationLogical. Should the output print to console. Default is FALSE which writes a new R script beginning with the value of
df
Details
Creates a new R script that comes pre-filled with roxygen2 comments. The new file is named "df_documentation" and is located in the "R/" folder in your package.
This function is based off of makeOxygen but is far more limited. Unlike makeOxygen this only works on objects that are data.frames or tibbles. This is because the purpose of this function is to automate the process of documenting the variables in a data frame by leveraging the underlying variable labels.
Another important difference between this function and makeOxygen is that this function allows you to either print the results to the home console or as a new script.
It should be noted that if a variable does not have a variable label, then it will not show up in the new R script.
Examples
# Add variable labels to iris dataset
library(labelled)
library(dplyr)
iris_labelled <- iris %>%
labelled::set_variable_labels(
Sepal.Length = "Length of the flower sepal, measured in millimeters",
Sepal.Width = "Width of the flower sepal, measured in millimeters",
Petal.Length = "Length of the flower petal, measured in millimeters",
Petal.Width = "Width of the flower petal, measured in millimeters",
Species = "The species of flower"
)
# if you want to print to the console instead of creating a new script
# just add print = TRUE to the function
make_df_oxy(iris_labelled, print = TRUE)
#> #' @title {dataset_title},
#> #' @description {dataset_description},
#>
#> #' @format A data frame with {nrow(df)} rows and {ncol(df)} variables:
#> #' \describe{
#> #' \item{Sepal.Length}{Length of the flower sepal, measured in millimeters}
#> #' \item{Sepal.Width}{Width of the flower sepal, measured in millimeters}
#> #' \item{Petal.Length}{Length of the flower petal, measured in millimeters}
#> #' \item{Petal.Width}{Width of the flower petal, measured in millimeters}
#> #' \item{Species}{The species of flower}
#> #'}
#>
#> "iris_labelled"