You are here:
Vanderbilt Biostatistics Wiki
>
Main Web
>
Seminars
>
RClinic
>
StripchartColorExample
(14 Nov 2006,
TheresaScott
)
(raw view)
E
dit
A
ttach
---+ Distinguishing a second categorical variable by color in a stripchart across groups For this example, I generated a dummy data set containing repeated measures --- I created data frame in wide format first (=y=) and then used the =reshape()= function to reshape the data to long format (=longy=). The stripchart shows =weight= across =time= with color of points designating =sex=. I used the =add= argument to add points from the second stripchart to the plot of the first stripchart. <highlight> y <- data.frame(id = 1:10, sex = sample(c("M", "F"), size = 10, replace = TRUE), weight.t1 = sample(150:250, size = 10), weight.t2 = sample(150:250, size = 10), weight.t3 = sample(150:250, size = 10)) longy <- reshape(y, varying = list(paste("weight.t", 1:3, sep="")), direction = "long", idvar = "id") # Stripchart: with(subset(longy, sex == "M"), stripchart(weight.t1 ~ time, method = "jitter", ylim = c(150, 250), vertical = TRUE,xlab="Time", ylab = "Weight", col = "red", pch = 20)) with(subset(longy, sex == "F"), stripchart(weight.t1 ~ time, method = "jitter", vertical = TRUE, col = "blue", pch = 20, add = TRUE)) par(xpd = NA) legend(3, 270, legend = c("Male", "Female"), col = c("red", "blue"), pch = 20) </highlight>
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r2
<
r1
|
B
acklinks
|
V
iew topic
|
Edit
w
iki text
|
M
ore topic actions
Topic revision: r2 - 14 Nov 2006,
TheresaScott
Main
Department Home Page
Biostatistics Graduate Program
Vanderbilt University Medical Center
Main Web
Main Web Home
Search
Recent Changes
Changes
Topic list
Biostatistics Webs
Archive
Main
Sandbox
System
Register
|
Log In
Copyright © 2013-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Vanderbilt Biostatistics Wiki?
Send feedback