options(knitr.duplicate.label = "allow")
knitr::opts_chunk$set(echo = TRUE, include= TRUE, message = TRUE)

Child START

child <- "child"
grandNchild <- "child"
parentNchild <- "child"
all <- "child"

varNames <- c("child", "parent", "grand",
                  "grandNchild", "grandNparent", "parentNchild", "all" )
vars <- sapply( varNames, function( var ) {
    ifelse( exists( var), get(var), "")
})

data.frame( Variable= vars,
            WantDirect= c("child", "", "", "child", "", "child", "child" ),
            WantParent= c("child", "parent", "", "child", "parent", "child", "child" ),
            WantGrand= c("child", "parent", "grand", "child", "parent", "child", "child" )
)

Child END



JefferysAnalysis/ComplexRmd documentation built on Dec. 18, 2021, 12:35 a.m.