# NOT RUN {
# quick example
library(magrittr)
library(fold)
x <- as.folded(system.file(package='metaplot','extdata','drug1001.fld'))
x %>% metaplot(
DV, IPRE, SEX,
ylog = TRUE,
xlog = TRUE,
grid = TRUE, # passed to xyplot
iso = TRUE,
ysmooth = TRUE,
xsmooth = TRUE,
yref = 0.5,
xref = 0.5,
main = TRUE,
corr = TRUE,
fit = TRUE,
conf = 1 - 1e-14,
loc = 6
)
# extended examples
# }
# 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
# x %>% as.csv('drug1001.fld')
# 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, main = TRUE) # categorical and continuous
x %>% metaplot(PRED,DV,SEX, main = TRUE) # 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)
x %>% metaplot(AGE,WEIGHT, ysmooth = TRUE)
x %>% metaplot(AGE,WEIGHT, ysmooth = TRUE, fit = TRUE)
x %>% metaplot(AGE,WEIGHT, ysmooth = TRUE, conf = TRUE)
x %>% metaplot(AGE,WEIGHT, ysmooth = TRUE, conf = TRUE, loc = 9)
x %>% metaplot(AGE,WEIGHT, ysmooth = TRUE, conf = TRUE, loc = c(.2,.7),
main = TRUE, corr = TRUE)
# FED ~ WEIGHT would normally invoke a boxplot.
# Here we force FED to be treated as numeric to illustrate logistic regression.
x %>% scatter('FED', 'WEIGHT', conf = TRUE)
# Alternatively:
x %>%
filter(is.na(META) | !(VARIABLE == 'FED' & META =='GUIDE')) %>%
metaplot(FED, WEIGHT, conf = TRUE)
# Below, x is TAD,
# plot is conditioned by ID
# ID is categorical (encoded)
x %>% metaplot(
DV, PRED, IPRE, TAD, ID,
color = 'black',
points = c(TRUE, FALSE, FALSE),
line = c('none','dashed','solid'),
ylab = 'plasma drug concentration (ng/mL)'
) %>% `[[`(1)
2-way facetting
x %>% metaplot(DV, PRED, TIME, SEX, FED,
line = 'none', color = c('blue','magenta'))
# }
Run the code above in your browser using DataLab