# NOT RUN {
# load some packages
library(spec)
library(csv)
library(magrittr)
library(tidyr)
library(dplyr)
library(fold)
# find paths to example data and specification
x <- system.file(package='metaplot','extdata','drug1001.csv')
spec <- system.file(package='metaplot','extdata','drug1001.spec')
# verify agreement at file level
x %matches% spec
# read and verify in memory
x %<>% as.csv
spec %<>% as.spec
x %matches% spec
# convert specifaction to folded format
spec %<>% as.folded
# capture the most interesting parts of x
x %<>% filter(VISIBLE == 1) %>% filter(EVID == 0)
# identify keys
attr(x, 'groups') <- c('ID','TIME')
# fold x
x %<>% fold
# combine with metadata
x %<>% bind_rows(spec)
x %<>% sort
# Now we have a plotting dataset with embedded metadata.
# We call metaplot with various numbers of continuous and
# categorical arguments, given as unquoted values from the
# VARIABLE column.
x %>% metaplot(AGE) # one continuous
x %>% metaplot(PRED,DV) # two continuous
x %>% metaplot(AGE,SEX) # continuous and categorical
x %>% metaplot(SEX,AGE) # categorical and continuous
x %>% metaplot(PRED,DV,SEX) # two continous and categorical
x %>% metaplot(ETA1,ETA2,ETA3) # three or more continuous
x %>% metaplot(CWRES,TAD) # metadata
x %>% filter(META %>% is.na) %>% metaplot(CWRES,TAD) # no metadata
x %>% metaplot(PRED,DV, xlog = TRUE, ylog = TRUE, iso=TRUE, xsmooth = TRUE) # log-log
x %>% metaplot(CWRES, TAD, yref = 0, ysmooth = TRUE)
x %>% metaplot(ETA1, SEX, ref = 0)
x %>% metaplot(AGE,WEIGHT, ysmooth = TRUE, xsmooth = TRUE)
# }
Run the code above in your browser using DataLab