I tried that too, it doesn't work because of the way I wrote the code. Listing y as free or not giving it a limit makes the scale go from -0.5 to 0.5, which is useless. This is what my code looks like now (it's S-Plus code, btw)-- I'll try reading up on lattices in R to see if I can come up with something better.
par(mfrow = c(2,2)) unique.id <- unique(d1$ID) unique.id <- sort(unique.id) for(j in unique.id){ temp.id <- d1[d1$ID==j,] unique.dose <-unique(temp.id$DOSE) plot(0,0,type="n", xlab= "Time (hr)",ylab="Concentration (ug/L)", xlim=c(0,32),ylim=c(0,200), main=paste("ID",j) ) for(i in unique.dose){ temp.subanddose <- temp.id[temp.id$DOSE==5,] points(temp.subanddose$TAD, temp.subanddose$DV,col=1,pch=1,) points(temp.subanddose$TAD, temp.subanddose$IPRE,type="l",col=1)} for(i in unique.dose){ temp.subanddose <- temp.id[temp.id$DOSE==7,] points(temp.subanddose$TAD, temp.subanddose$DV,col=2,pch=2,) points(temp.subanddose$TAD, temp.subanddose$IPRE,type="l",col=2)} for(i in unique.dose){ temp.subanddose <- temp.id[temp.id$DOSE==10,] points(temp.subanddose$TAD, temp.subanddose$DV,col=3,pch=3,) points(temp.subanddose$TAD, temp.subanddose$IPRE,type="l",col=3)} key(text=list(c("5 mg", "7 mg", "10 mg")),lines=list(type=rep ("l",3),col=1:3),border=T,corner=c(1,1)) } On Fri, Oct 15, 2010 at 1:31 AM, David Winsemius <dwinsem...@comcast.net>wrote: > > On Oct 15, 2010, at 3:46 AM, Anh Nguyen wrote: > > Hello Dennis, >> >> That's a very good suggestion. I've attached a template here as a .png >> file, >> I hope you can view it. This is what I've managed to achieve in S-Plus (we >> use S-Plus at work but I also use R because there's some very good R >> packages for PK data that I want to take advantage of that is not >> available >> in S-Plus). The only problem with this is, unfortunately, I cannot figure >> out how make the scale non-uniform and I hope to fix that. >> > > That would be easy if your efforts which I have not yet seen were in > lattice. If htat were the case then adding this would solve you problem: > > scales=list(y=list(relation="free") > > -- > David > >> My data looks >> like this: >> >> ID Dose Time Conc Pred ... >> 1 5 0 0 0 >> 1 5 0.5 6 8 >> 1 5 1 16 20 >> ... >> 1 7 0 0 0 >> 1 7 0.5 10 12 >> 1 7 1 20 19 >> ... >> 1 10 3 60 55 >> ... >> 2 5 12 4 2 >> ... >> ect >> >> >> I don't care if it's ggplot or something else as long as it looks like how >> I >> envisioned. >> >> >> >> >> On Fri, Oct 15, 2010 at 12:22 AM, Dennis Murphy <djmu...@gmail.com> >> wrote: >> >> I don't recall that you submitted a reproducible example to use as a >>> template for assistance. Ista was kind enough to offer a potential >>> solution, >>> but it was an abstraction based on the limited information provided in >>> your >>> previous mail. If you need help, please provide an example data set that >>> illustrates the problems you're encountering and what you hope to achieve >>> - >>> your chances of a successful resolution will be much higher when you do. >>> BTW, there's a dedicated newsgroup for ggplot2: >>> look for the mailing list link at http://had.co.nz/ggplot2/ >>> >>> HTH, >>> Dennis >>> >>> >>> On Thu, Oct 14, 2010 at 10:02 PM, Anh Nguyen <eataban...@gmail.com> >>> wrote: >>> >>> I found 2 problems with this method: >>>> >>>> - There is only one line for predicted dose at 5 mg. >>>> - The different doses are 5, 7, and 10 mg but somehow there is a legend >>>> for >>>> 5,6,7,8,9,10. >>>> - Is there a way to make the line smooth? >>>> - The plots are also getting a little crowded and I was wondering if >>>> there >>>> a >>>> way to split it into 2 or more pages? >>>> >>>> Thanks for your help. >>>> >>>> On Thu, Oct 14, 2010 at 8:09 PM, Ista Zahn <iz...@psych.rochester.edu >>>> >>>>> wrote: >>>>> >>>> >>>> Hi, >>>>> Assuming the data is in a data.frame named "D", something like >>>>> >>>>> library(ggplot2) # May need install.packages("ggplot2") first >>>>> ggplot(D, aes(x=Time, y=Concentration, color=Dose) + >>>>> geom_point() + >>>>> geom_line(aes(y = PredictedConcentration, group=1)) + >>>>> facet_wrap(~ID, scales="free", ncol=3) >>>>> >>>>> should do it. >>>>> >>>>> -Ista >>>>> On Thu, Oct 14, 2010 at 10:25 PM, thaliagoo <eataban...@gmail.com> >>>>> >>>> wrote: >>>> >>>>> >>>>>> Hello-- I have a data for small population who took 1 drug at 3 >>>>>> >>>>> different >>>> >>>>> doses. I have the actual drug concentrations as well as predicted >>>>>> concentrations by my model. This is what I'm looking for: >>>>>> >>>>>> - Time vs Concentration by ID (individual plots), with each subject >>>>>> occupying 1 plot -- there is to be 9 plots per page (3x3) >>>>>> - Observed drug concentration is made up of points, and predicted drug >>>>>> concentration is a curve without points. Points and curve will be the >>>>>> >>>>> same >>>>> >>>>>> color for each dose. Different doses will have different colors. >>>>>> - A legend to specify which color correlates to which dose. >>>>>> - Axes should be different for each individual (as some individual >>>>>> >>>>> will >>>> >>>>> have >>>>> >>>>>> much higher drug concentration than others) and I want to see in >>>>>> >>>>> detail >>>> >>>>> how >>>>> >>>>>> well predicted data fits observed data. >>>>>> >>>>>> Any help would be greatly appreciated. >>>>>> -- >>>>>> View this message in context: >>>>>> >>>>> >>>>> >>>> http://r.789695.n4.nabble.com/Time-vs-Concentration-Graphs-by-ID-tp2996431p2996431.html >>>> >>>>> Sent from the R help mailing list archive at Nabble.com. >>>>>> >>>>>> ______________________________________________ >>>>>> R-help@r-project.org mailing list >>>>>> https://stat.ethz.ch/mailman/listinfo/r-help >>>>>> PLEASE do read the posting guide >>>>>> >>>>> http://www.R-project.org/posting-guide.html >>>>> >>>>>> and provide commented, minimal, self-contained, reproducible code. >>>>>> >>>>>> >>>>> >>>>> >>>>> -- >>>>> Ista Zahn >>>>> Graduate student >>>>> University of Rochester >>>>> Department of Clinical and Social Psychology >>>>> http://yourpsyche.org >>>>> >>>>> >>>> [[alternative HTML version deleted]] >>>> >>>> >>>> ______________________________________________ >>>> R-help@r-project.org mailing list >>>> https://stat.ethz.ch/mailman/listinfo/r-help >>>> PLEASE do read the posting guide >>>> http://www.R-project.org/posting-guide.html >>>> and provide commented, minimal, self-contained, reproducible code. >>>> >>>> >>> >>> <ex.png>______________________________________________ >> >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > David Winsemius, MD > West Hartford, CT > > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.