-
Notifications
You must be signed in to change notification settings - Fork 4
/
testing.R
83 lines (66 loc) · 2.33 KB
/
testing.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
library(xpose4)
library(ggplot2)
## load example
data(simpraz.xpdb)
xpdb <- simpraz.xpdb
xpdb@[email protected]$aspect <- "fill"
## coder settings
andy <- FALSE # change
if (andy) {
cur.dir <- getwd()
setwd("/Users/ahooker/Documents/Xpose/Examples/other_examples/Andy_Simpraz")
xpdb <- xpose.data(5)
setwd(cur.dir)
} else {
setwd("~/git/ggXpose")
}
## Try lattice basic plot
xpose.plot.default("TIME","DV",xpdb) # lattice version
## ggplot2 basic plot
source("xpose.plot.default.R")
xpose.plot.default("TIME","DV",xpdb) # new ggplot version
rm("xpose.plot.default")
xpose.plot.default("TIME","DV",xpdb) # lattice version again
## standard xpose plots (lattice)
source("xpose.plot.default.R")
wres.vs.idv(xpdb) # standard xpose version
dv.vs.pred(xpdb)
## standard xpose plots (ggplot2)
environment(wres.vs.idv) <- .GlobalEnv
environment(dv.vs.pred) <- .GlobalEnv
wres.vs.idv(xpdb) # ggplot version
dv.vs.pred(xpdb)
## Feature: adding geoms [works]
tmp <- wres.vs.idv(xpdb)
tmp + geom_line(aes(group=ID))
## Feature: stratify using facet_wrap/grid
## status: mostly working, but all .by.cov functions need to be changed.
rm("xpose.plot.default")
change.xvardef(xpdb, "covariates") <- c("SEX", "RACE")
dv.vs.pred.by.cov(xpdb, grid = TRUE, ids = TRUE) # lattice version
source("xpose.plot.default.R")
environment(dv.vs.pred.by.cov) <- .GlobalEnv
dv.vs.pred.by.cov(xpdb, grid = TRUE, ids = TRUE) # ggplot2 version
# 1 var, facet_grid:
xpose.plot.default(xvardef("pred", xpdb), xvardef("dv", xpdb), object=xpdb, by=c("SEX"), facet="grid")
# 1 var, facet_wrap: [not working yet, using facet_grid in code]
xpose.plot.default(xvardef("pred", xpdb), xvardef("dv", xpdb), object=xpdb, by=c("SEX"), facet="wrap")
# 2 vars:
xpose.plot.default(xvardef("pred", xpdb), xvardef("dv", xpdb), object=xpdb, by=c("SEX","SMOK"))
# higher-level function:
source("dv.vs.pred.by.cov.gg.R")
dv.vs.pred.by.cov(xpdb, grid=TRUE, ids=TRUE)
## Feature: coloring of lines
## Feature: adding ablines / smooths
## Feature: ...
####################################################################################
## VPC example
setwd("vpc_example")
# lattice:
library(xpose4)
xpose.VPC(vpc.info="vpc_run5/vpc_results.csv",
vpctab="vpc_run5/vpctab5")
# ggplot2
source("../xpose.VPC.gg.R")
xpose.VPC(vpc.info="vpc_run5/vpc_results.csv",
vpctab="vpc_run5/vpctab5")