vartors: Transform Definition of Variables to R Scripts

Description Details Note Author(s) See Also Examples

Description

vartors is an R package that produces R script using definition of variables described by user. It could help to import, adapt to R classes and perform descriptive analysis on each variable according to its type.

Details

Documentation

This page explain the main concepts in vartors. See also the vignettes. There is one with a tutorial :

vignette(topic = "usage", package = "vartors")

and one with the complete workflow

vignette(topic = "workflow", package = "vartors")

Motivation

The package vartors was created to speed-up the error-prone and important cleaning data phase in context of the statistical consultations. These methodology consultations are an important part of our daily work. The idea is to help physicians of our hospital to process their data and make accurate analysis. In our workflow, the physician must come with a database (mainly an Excel or .csv file), a description of the variables and a good question. For the moment, we spend too much time to clean up data and not enough to analyze it. That's where vartors may help.

Workflow

We will describe here in a compact way the workflow. For more details, see the documentation of each function and the vignettes.

The global workflow is :

  1. Create a definition of variables table. The descvars_skeleton function could help you to initiate this. Fill all the characteristics of each variable, especially the type.

  2. Import this definition of variables table in R if it was created in a spreadsheet program, for example with read.csv, read.table or read.xlsx, to have it in data.frame.

  3. Use create_script to create a script according to the definition of each variable.

  4. Write this script in a file with write_file

  5. Adapt your new script to special cases, test it line by line, and produce a report, for example with knitr

It's possible to use various built-ins script templates in .R or .Rmd with the function import_template. The user could also create his own script templates by exporting a built-in one with export_template. It's a flexible way to allow each user to adapt and perform analysis on each variable as he want.

Note

For bugreports, features request, use the github issue tracking at https://github.com/jomuller/vartors/issues.

Special thanks to :

Author(s)

Joris Muller

See Also

The mains methods are create_script, import_template and import_vardef. The main work to the user is to fill a definition of variables table.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Import a data.frame containing the description of the variables
# Show the description of the variable
sample_descvar

# Create the script skeleton simply with create_script()
script_skeleton <- create_script(sample_descvar)
# watch the result
script_skeleton
# Could be written in a file with the write() method
## Not run: 
write_file(script_skeleton)

## End(Not run)

# It's possible to create a simple script for a single variable
a_variable_definition <- vardef(varlabel = "Creatinine Clearance", rname ="creat", type="numeric" )
create_script(a_variable_definition)

jomuller/vartors documentation built on May 19, 2019, 7:26 p.m.