-
Notifications
You must be signed in to change notification settings - Fork 14
/
mittal.R
38 lines (26 loc) · 1008 Bytes
/
mittal.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
# plots several curves, one for each gorup, against a common X-axis, as
# in qePlotCurves, but showing the change in each variable, relative to
# the variable's value at min X
# X is typically input in ascending numerical order, but need not be
# X is required to be in col 1; col 2 is for Y of group 1, etc.
# 'data' must be a data frame or equivalent, in which for each X value
# there is exactly one Y value for each group; format is wide, e.g.
# x y1 y2 y3
# w <- data.frame(x=c(3:5,2),y1=c(5:7,4),y2=c(4,12,15,5),y3=10:7)
# qeMittalGraph(w)
qeMittalGraph <- function(data,xlab='x',ylab='y',legendTitle='curve')
{
x <- data[,1]
nc <- ncol(data)
argMinX <- which.min(data$x)
nms <- names(data)[-1]
z <- lapply(1:(nc-1),
function(i) {
tmp <- data[,i+1] / data[argMinX,i+1]
tmpDF <- data.frame(x=x,curveNum=nms[i],y=tmp)
tmpDF
}
)
zz <- do.call(rbind,z)
qePlotCurves(zz,1,3,2,xlab=xlab,ylab=ylab,legendTitle=legendTitle)
}