knitr::opts_chunk$set(echo = TRUE)
library(vtree)

Pruning revised

(r1 <- vtree(FakeData,"Severity Sex",sameline=TRUE))
grVizToPNG(r1,width=3000,folder="png")
(r2 <- vtree(FakeData,"Severity Sex",sameline=TRUE,
  prune=list(Severity=c("Mild","Moderate"))))
grVizToPNG(r2,width=3000,folder="png")

vtree(FakeData,"Group Category",sameline=TRUE)

(r3 <- vtree(FakeData,"Category Group",sameline=TRUE))
grVizToPNG(r3,width=3000,folder="png")
(r4 <- vtree(FakeData,"Category Group",sameline=TRUE,
  prunebelow=list(Category=c("single","double"))))
grVizToPNG(r4,width=3000,folder="png")
(r5 <- vtree(FakeData,"Category Group",sameline=TRUE,
  keep=list(Category=c("single","double"))))
grVizToPNG(r5,width=3000,folder="png")
(r6 <- vtree(FakeData,"Category Group",sameline=TRUE,
  follow=list(Category=c("single","double"))))
grVizToPNG(r6,width=3000,folder="png")
(r7 <- vtree(FakeData,"Category Group",sameline=TRUE,showlegend=TRUE))
grVizToPNG(r7,width=3000,folder="png")

Basics

(v1 <- vtree(FakeData,"Severity Sex",NAfillcolor="#FFFDFD"))
grVizToPNG(v1,width=3000,folder="png")
(v1a <- vtree(FakeData,"Severity Sex",squeeze=0.8))
grVizToPNG(v1a,width=3000,folder="png")
(v2 <- vtree(FakeData,"Group",horiz=FALSE))
grVizToPNG(v2,width=3000,folder="png")
(v3 <- vtree(FakeData,"Category Group",sameline=TRUE,
  showlegend=TRUE))
grVizToPNG(v3,width=3000,folder="png")

Variable specification modifiers

Modifier | Effect -----------------|------------------------------------------------- prefix is.na: | replace variable with missing value indicator prefix stem: | include all variables from REDCap with names based on stem prefix tri: | within each node, replace variable with trichotomized variable variable=value | dichotomize variable at value variable<value | dichotomize variable below value variable>value | dichotomize variable above value

Pruning

Parameter | Effect --------------|--------------------------------------------------- prune | remove all specified nodes prunebelow | remove all descendants of the specified nodes keep | retain only the specified nodes follow | retain descendants of only the specified nodes

(v4 <- vtree(FakeData,"Severity Sex",
  prune=list(Severity=c("Mild","Moderate"))))
grVizToPNG(v4,width=3000,folder="png")
(v5 <- vtree(FakeData,"Severity Sex",
  prunebelow=list(Severity=c("Mild","Moderate"))))
grVizToPNG(v5,width=3000,folder="png")
(v6 <- vtree(FakeData,"Severity Sex",
  keep=list(Severity=c("Mild","NA"))))
grVizToPNG(v6,width=3000,folder="png")
(v7 <- vtree(FakeData,"Severity Sex",
  follow=list(Severity=c("Mild","NA"))))
grVizToPNG(v7,width=3000,folder="png")

Labeling

Parameter | Example --------------|---------------------------------------------- labelvar | labelvar=c(Severity="New label for Severity") labelnode | labelnode=list(Sex=c(Male="M",Female="F")) tlabelnode | tlabelnode=list(c(Group="A",Sex="F",label="girl"))

Text

Code | Effect ----------------------|-------------------------- \n | Line break *...* | Italics **...** | Bold ^...^ | Superscript ~...~ | Subscript %%red ...%% | Make text red (or whatever color)

(v8 <- vtree(FakeData,"Group Category",sameline=TRUE,
  text=list(Category=c(triple="\n*not verified*"))))
grVizToPNG(v8,width=3000,folder="png")
(v9 <- vtree(FakeData,"Severity Age Pre Post",check.is.na=TRUE))
grVizToPNG(v9,width=3000,folder="png")

Summary

Statistic codes

Code | Result :---------------|:------------------------------------------------------------------- %mean% | mean %SD% | standard deviation %min% | minimum %max% | maximum %pX% | Xth percentile (e.g. p50 means the 50th percentile) %median% | median, i.e. p50 %IQR% | IQR, i.e. p25, p75 %npct% | frequency and percentage %pct% | just percentage %list% | list of individual values, separated by commas %listlines% | list of individual values, each on a separate line %mv% | the number of missing values %trunc=n% | flag: Truncate the summary to the first n characters.

Restriction codes

Code | Summary information restricted to: :---------------|:--------------------------------------- %noroot% | all nodes except the root %leafonly% | leaf nodes %var=v% | nodes of variable v %node=n% | nodes named n

Variable specification modifiers

Modifier | Effect -----------------|------------------------------------------------- variable=value | dichotomize variable at value variable<value | dichotomize variable below value variable>value | dichotomize variable above value

(v10 <- vtree(FakeData,"Severity",sameline=TRUE,
  summary="Score , mean=%mean%"))
grVizToPNG(v10,width=3000,folder="png")


nbarrowman/vtree documentation built on Jan. 11, 2024, 5:52 a.m.