knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(TableRExtracts) library(dplyr) library(magrittr)
The TableRExtracts package is useful for creating table extracts and codebooks for datasets within R. Table extracts are created as comma-separated value (.csv) files that provide summary statistics for variables in the dataset. The benefit of creating extracts is that they can populate tables created in Excel with dynamic links between the table and the extract (both sheets in Excel). If something changes with the dataset and the summary statistics need to be updated, the table extract can be rerun and replaced in the Excel file and the tables will automatically be updated.
This vignette provides an overview for the extract process: 1. Add labels to the variables and values in the dataset 1. Determine the summary statistics of interest 1. Create table extracts 1. Set-up dynamically loaded tables in Excel 1. Copy the extract to the Excel file
We will begin by creating labels for the variables and values in this dataset. It is possible to add variable labels one variable at a time. The same is true of values and value labels which can be added one variable at a time or to multiple variables in a single command.
This section will focus on adding labels to the college_grads dataset provided as part of the TableRExtracts package.
To explore adding labels to variables and values, we'll use college_grads. This
data frame contains 173 observations corresponding to 173 different majors.
The author of the
college_grads
AddVarLabels(college_grads) <- c("Total" = "Total number of people with major", "Men" = "Male graduates", "Women" = "Female graduates")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.