Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

vtree cheatsheet

Basics Pruning Text summary parameter


Draw a basic variable tree Prune single and double and their descendants Add text to nodes Syntax: summary=" varspec format "
vtree(FakeData,"Severity Sex") vtree(FakeData,"Category Group",sameline=TRUE, vtree(FakeData,"Group Category",sameline=TRUE,
prune=list(Category=c("single","double"))) text=list(Category=c(triple="\n*not verified*"))) varspec variable specification format text and codes

Code Effect Variable specification Effect


variable=x x vs. all other values
\n Line break
variable>x below x vs. all other values
*...* Italics
variable<x above x vs. all other values
**...** Bold
^...^ Superscript Code Produces
~...~ Subscript %mean% mean
%%red ...%% Make text red (or another color) %SD% standard deviation
%sum% sum
Targeted text (text in a specific node) %min% minimum
ttext=list(Group="A",Severity="Mild",text="hi") %max% maximum
%pX% Xth percentile
%median% median, i.e. p50
Only keep single and double and their descendants
R Markdown %IQR% IQR, i.e. p25, p75
vtree(FakeData,"Category Group",sameline=TRUE, %npct% frequency and percentage
`r vtree(FakeData,"Group Category")`
keep=list(Category=c("single","double"))) %pct% just percentage
Parameter setting Effect %list% comma-separated list of values
imagewidth="3in" Image 3 inches wide %listlines% individual values on separate lines
imageheight="4in" Image 4 inches tall %mv% the number of missing values
pxwidth=800 Image 800 pixels wide %nonmv% the number of non-missing values
pxheight=2000 Image 200 pixels high
Code Restricts summary information to:
pngknit=FALSE Use htmlwidgets instead of PNG
%noroot% all nodes except the root
%leafonly% leaf nodes
Parameter setting Effect Variable specification %var=v% nodes of variable v
vp=FALSE Use full denominator for %
%node=n% nodes named n
horiz=FALSE Vertical variable tree Prefix Effect
sameline=TRUE Node labels on same line as is.na: is.na(variable)
splitwidth=50 the counts
Split and50
text after percentages
chars stem: all REDCap variables starting with stem Pattern trees and tables
getscript=TRUE Get DOT script rc: flag variable as a REDCap checkbox
plain=TRUE Nodes in shades of blue Other ways to prune Effect tri: variable
trichotomize in each node of variable
digits=1 1 decimal place in % prunebelow Prune below nodes
cdigits=2 2 dec. places in summary Suffix Effect n pct Severity Sex
follow Only follow specified nodes 2 4 Severe F
showpct=FALSE Do not show % this* variable names starting with this
prunesmaller Prune smaller nodes 3 7 <NA> F
Do not show counts variable names starting with this 3 7 <NA> M
showcount=FALSE this#
and ending with numeric digits 3 7 Severe M
5 11 Moderate M
Labels Dichotomize Effect
8 17
11 24
Mild
Mild
M
F
variable=x x vs. all other values 11 24 Moderate F
Parameter setting Effect variable<x below x vs. all other values
labelvar=c(Ind1="Indicator1") Relabel Ind1 variable>x above x vs. all other values
labelnode=list(MyVar=c(New="Old",New2="Old2")) Change node labels
tlabelnode=list(c(Group="A",Sex="F",label="girl") Change the label of a specific node
varnamepointsize=15 Set font size (points) for variable names Additional functions Parameter setting Effect
shownodelabels=FALSE Do not show node labels pattern=TRUE Generate a pattern tree
Function Purpose
showvarnames=FALSE Do not show variable names Venn=TRUE Use Venn settings for indicator variables
VennTable Format pattern table
showlegend=TRUE Show a legend ptable=TRUE Generate a pattern table
crosstabToCases Convert a crosstab array to cases
title="All businesses" Show a title for the root node check.is.na=TRUE Generate a pattern table for missing values
grVizToPNG Generate a PNG file
Generate a data frame from Format a pattern table for markdown
build.data.frame
specified counts VennTable(vtree(FakeData,"Ind1 Ind2",ptable=T),markdown=T)

CC by Nick Barrowman https://creativecommons.org/licenses/by/4.0/ • Learn more at https://github.com/nbarrowman/vtree/ • package version 3.0.0 available on CRAN • updated Oct 17, 2019

You might also like