Description Usage Arguments Details Value Author(s) Examples
The contents() function creates two tables similar to those that are generated by SAS PROC CONTENTS: 1) Summary table with number of observations, rows, and file size; 2) A list of all variables (alphabetically or by variable number) with the option to write them to an excel sheet or an RTF file.
1 |
data |
dataframe used in the analysis |
varnum |
boolean input controlling order or variable list - set to false for alphabetical variable list. |
write |
OPTIONAL - character string either "word" or "excel" - controls whether to write to file and which file type. |
outfile |
File path for output file folder. Required if write argument is specified. |
filename |
File name for output file - DO NOT include file type extension. Required if write argument is specified. |
Generates two tables akin to output from SAS Proc Contents - 1 with summary information (i.e. name of dataframe, number of observations, and number of variables) and a second with a list of variables. Includes option to order the variable table alphabetically or by variable number (default, equivalent to the index value). Includes additional option to output to a word doc or excel file allowing the user to specify a file path. In the current iteration, the file path and file name must be specified separately in the outfile and filename arguments.
Dependent packages: dplyr, xlsx, officer
The function returns a 2 level list with the following tables:
metadata |
4 line table with dataframe name, number of observations, number of variables and object size (in bytes) |
var_table |
Table showing all variables in dataframe along with factor levels, and labels (if pulled in from SAS) |
James Hodge
1 2 3 4 5 6 7 8 9 10 11 | #-------------- Examples using base data set mtcars
# Default usage will sort variables by index number
test1 <- contents(data = mtcars)
test1$metadata
test1$var_table
# Changing the varnum option will order variables alphabetically
test2 <- contents(data = mtcars, varnum = F)
test2$metadata
test2$var_table
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.