[R] Plots by subject

Tanya Murphy tmurph6 at po-box.mcgill.ca
Tue Sep 10 00:56:24 CEST 2002


Hello! I need some help with creating plots for each study subject. I have 
tried the 'for' command as described in 'An Introduction to R', but I wasn't 
successful.

Here's what I want to do:
-Create and save the following overlayed scatterplots for each subject (1 to 
n).
-The data frame is in the form of one line per visit per subject (so more than 
one line per subject). (I thought this may be why the 'split' and 'for' 
functions didn't do it for me.)

This works one subject:

pt <- ID == '1'
par(oma=c(0,2,0,3))
plot(VISITWK[pt], T4[pt], ylim=c(0,500), xlim=c(0,50), xlab='Visit week', 
type='b', ylab='CD4 count (cells/ul) [-o-]')
par(new=T)
plot(VISITWK[pt], LOG.BDUS[pt], ylim=c(1,6), xlim=c(0,50), pch='+', axes=F, 
ylab='', type='b', xlab='', main='Viral load and CD4 for ID=1')
axis(4)
mtext("Viral load (log10) [-+-]",4, outer=T)
savePlot(filename='ID_1', type=c('pdf'))

Is there something like a macro variable that I can use in the plot arguments 
and in the title and filename (or at least some way to save all the plots)?

A second minor thing: the headings in the HTML help and R web pages show up as 
strange characters - any advice?

Thanks for your time!

Tanya

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list