Re: [R] Loop for multiple plots in figure

2012-06-27 Thread baptiste auguie
You can use main = unique(d$Subject) to solve this problem. HTH, b. On 27 June 2012 08:49, Marcel Curlin wrote: > Well at this point I have what I need (rough plot for data exploration) but > the simplicity of the first approach is quite elegant and it has become a > learning project. I have su

Re: [R] Loop for multiple plots in figure

2012-06-27 Thread Marcel Curlin
Well at this point I have what I need (rough plot for data exploration) but the simplicity of the first approach is quite elegant and it has become a learning project. I have succeeded in formatting the overall plot OK but have not been able to solve the problem of titles or any kind of label/legen

Re: [R] Loop for multiple plots in figure

2012-06-26 Thread baptiste auguie
Try this alternative solution using only base functions: # split the data into 4 data.frames l <- split(data, data$Subject) names(l) # set up the graph parameters par(mfrow=n2mfrow(length(l)), mar=c(4,4,1,1), mgp = c(2, 1, 0)) # good old for loop over the subject names for( n in names(l)){ d <-

Re: [R] Loop for multiple plots in figure

2012-06-26 Thread Marcel Curlin
This solution works really nicely & I learned much by working through it. However but I am having trouble with subplot formatting; setting main=d$Subject results in the correct title over each plot but repeated multiple times. Also I can't seem to format the axis labels and numbers to reduce the sp

Re: [R] Loop for multiple plots in figure

2012-06-25 Thread baptiste auguie
Hi, Here's one approach: plot_one <- function(d){ with(d, plot(Xvar, Yvar, t="n")) # set limits with(d[d$param1 == 0,], lines(Xvar, Yvar, lty=1)) # first line with(d[d$param1 == 1,], lines(Xvar, Yvar, lty=2)) # second line } par(mfrow=c(2,2)) plyr::d_ply(data, "Subject", plot_one) HTH,

[R] Loop for multiple plots in figure

2012-06-24 Thread Marcel Curlin
Hello, I have longitudinal data of the form below from N subjects; I am trying to create figure with N small subplots on a single page, in which each plot is from only one subject, and in each plot there is a separate curve for each value of param1. So in this case, there would be four plots on t