Re: [R] xYplot help
xYplot has many options that are passed to panel.xYplot. Did you read the documentation? You can suppress labels, use an automatically generated Key() function to control where you want keys, and use several other options. Start with label.curve=FALSE and go from there. Frank bwr87 wrote I'm trying to work the lattice xYplot function to plot confidence intervals for two groups on the same plot. The problem is that it automatically labels the groups (1 and 2) on the plot itself, and the labels get obscured by the CI lines and make it look bad. This is my code: xYplot(Cbind(Mean,L95,U95) ~ jitter(Time), type='b', data=A,main=Bouts Vs. Time,col=c('black', 'gray'), groups=Group,title=Bouts,xlab=Time, ylab=Bouts, method=bars, lwd=3, ylim=c(0,30)) A is the data, with columns Time, Group, Mean, L95, U95. L95 and U95 are the lower and upper confidence interval estimates. Group is either 1 or 2, each measured at the same number of time points. The goal is simply to take the labels off of the plot itself. Then I can use an auto.key to put the labels on the side. Please help! -Ben [[alternative HTML version deleted]] __ R-help@ 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. - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/xYplot-help-tp4660102p4660108.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.
Re: [R] xyplot help
I am ploting gridded time series data. I would like the actual lat and lon value appear on the graph-if possible inside the graph as numbers. If there is also more elegant ways to plot the graphs I will appreciate more suggestions. # library(ggplot2) library(lattice) month - c(Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec) month - factor(month, levels = month.abb) data - as.data.frame(expand.grid(lon=seq(4,5, 1), lat=seq(-3,-2,1), year=seq(2010, 2012,1), month=month)) n=nrow(data) data$prec - rgamma(n, 2, 0.25) data$year - factor(data$year) data$lon - factor(data$lon) data$lat - factor(data$lat) ndata - data[order(data$lon, data$lat),] fix(ndata) max - max(ndata$prec, na.rm=TRUE) min - min(ndata$prec, na.rm=TRUE) #Plot the graph and save as pdf pdf(H:/file.pdf) xyplot(prec~month|year+lon+lat, data=ndata, type = c(l, l,p), ylim=c(min, max), layout=c(1,4)) dev.off() ## #I want to remove the lat and lon rows and put the numbers inside the graph Peter Maclean Department of Economics UDSM [[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.
Re: [R] xyplot help
Hi Peter As for more suggestions library(latticeExtra) useOuterStrips( xyplot(prec~month|year*paste(lat,lon), data=ndata, as.table = T, type = c(l, l,p), ylim=c(min, max), layout=c(1,4)) ) have a look at ?strip.custom and ?strip.default as well as ?useOuterStrips for customizing the strips and ?panel.text for within the panel. HTH Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email: home: mac...@northnet.com.au At 18:13 20/02/2013, you wrote: Content-Type: text/plain Content-Disposition: inline Content-length: 1370 I am ploting gridded time series data. I would like the actual lat and lon value appear on the graph-if possible inside the graph as numbers. If there is also more elegant ways to plot the graphs I will appreciate more suggestions. # library(ggplot2) library(lattice) month - c(Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec) month - factor(month, levels = month.abb) data - as.data.frame(expand.grid(lon=seq(4,5, 1), lat=seq(-3,-2,1), year=seq(2010, 2012,1), month=month)) n=nrow(data) data$prec - rgamma(n, 2, 0.25) data$year - factor(data$year) data$lon - factor(data$lon) data$lat - factor(data$lat) ndata - data[order(data$lon, data$lat),] fix(ndata) max - max(ndata$prec, na.rm=TRUE) min - min(ndata$prec, na.rm=TRUE) #Plot the graph and save as pdf pdf(H:/file.pdf) xyplot(prec~month|year+lon+lat, data=ndata, type = c(l, l,p), ylim=c(min, max), layout=c(1,4)) dev.off() ## #I want to remove the lat and lon rows and put the numbers inside the graph Peter Maclean Department of Economics UDSM [[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. __ 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.
[R] xyplot - help please
Dear R Gurus! I would like to generate a multi-panel plot with grouped and reference lines in each panel .. Example dataset and code are provide below. Where am I getting wrong in the code below? Any assistance will be highly appreciated. Thanks so much! -Santosh start dataset --- X,l,y1,y2,y3,y4,f -99,15,0.178,0.127,0.152,0.116,a 0,0,0.218,0.12,0.174,0.145,a 6,0.0015561,0.227,0.122,0.175,0.148,a 11,0.018907,0.213,0.12,0.176,0.145,a 17,0.079668,0.204,0.105,0.153,0.16,a 22,0.2368,0.216,0.121,0.175,0.148,a 27,0.58763,0.217,0.122,0.175,0.148,a 32,1.3433,0.223,0.118,0.17,0.145,a 37,2.7883,0.214,0.115,0.172,0.146,a 42,5.6097,0.22,0.121,0.175,0.147,a 47,11.018,0.216,0.12,0.176,0.145,a -99,15,0.178,0.127,0.152,0.116,b 4,0.0015561,0.159,0.145,0.114,0.543,b 8,0.018907,0.161,0.145,0.116,0.544,b 12,0.079668,0.143,0.139,0.121,0.539,b 17,0.2368,0.161,0.145,0.114,0.549,b 20,0.58763,0.161,0.145,0.116,0.546,b 25,1.3433,0.162,0.144,0.115,0.556,b 29,2.7883,0.162,0.144,0.115,0.549,b 33,5.6097,0.099,0.1,0.302,0.799,b 37,11.018,0.161,0.144,0.114,0.557,b end dataset --- library(reshape) options(scipen=12) my.settings - list(plot.symbol = list(col = c(red, blue), pch = 20,alpha=c(0.8, 0.8)), plot.line = list(col = c(red, blue), lty = c(2,3))) x1 - read.csv(ex1.csv,as.is=T) y1 - melt(x1,measure.vars=names(x1)[3:(length(names(x1))-1)],stringsAsFactors=F) y1a - y1[order(y1$f,y1$l),] # ref - y1a[y1a$X0,] xyplot(value~l|variable,groups=f,main=Compare parameter estimates, outer=T,allow.mult=T, data=y1a[y1a$X0,], strip=strip.custom(strip.names=T,strip.levels=T,var.name=Par), prepanel=function(x,y,group.number,..., horizontal) { rngy - range(y,finite=T) rngx - range(x,finite=T) list(ylim=rngy,xlim=rngx) }, panel.superpose, panel.xyplot, panel.groups = function(x, y, group.number,subscripts=subscripts, ..., horizontal) { opar - trellis.par.get() on.exit(trellis.par.set(opar)) rv - ref$value[ref$variable%in%sort(unique(y1$variable))[panel.number()]] trellis.par.set(list(plot.symbol = Rows(my.settings$plot.symbol,group.number), plot.line = Rows(my.settings$plot.line,group.number))) panel.xyplot(x, y, horizontal = horizontal) panel.abline(h=rv,col='green') }, xlab=Levels,ylab=Values, scale=list(x=list(log=T,at=c(0.01,0.1,1,10,15), lab=c(0.01,0.1,1,10,15),rot=45),rela=free), auto.key=list(space=bottom,columns=2)) [[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.
[R] xyplot help
Hi, I am learning xyplot. I have an example dataset attached. plotdata-read.table(plotdata.txt,sep='\t',header=T,row.names=1) head(plotdata,n=4) y x type 1 -4.309601 -0.7448405A 2 -4.715421 0.7875994A 3 -2.310638 0.5455310A 4 -2.685803 10.4116868A xyplot(y~x,groups=type,plotdata, auto.key=T) This shows different colors for different levels of type. Now, I want to add a fitted line to the plot, the formula is -1.324+0.1117*x-0.0006357*x*x I tried the following code to do this: xyplot(y~x,groups=type,plotdata, auto.key=T , panel = function(x,y) { panel.xyplot(x,y, type='p') x-sort(x) panel.lines(x,-1.324+0.1117*x-0.0006357*x*x) }) Now, it doesn't show different colors for different levels of type. How can I restore that? Also, is there anyway to put the legend at bottom of the plot (instead at the top right now)? And is there anyway to print legend horizontally, instead of vertically as shown right now? Thanks John y x type 1 -4.30960132841301 -0.744840518760792 A 2 -4.71542109959628 0.787599395527709 A 3 -2.31063823031730 0.545530976094587 A 4 -2.68580284811662 10.4116867886136A 5 0.857277739439742 45.8678415780720A 6 2.4572713553700584.8497464051184A 7 2.13169532824448103.133586922502A 8 1.28410512992259105.748839904875A 9 -1.03955702898241 -0.899013850822378 A 10 0.829280624483265 2.98715094752831A 11 -0.50214940111739 1.72294341018182A 12 3.1178629464421320.4231486028650A 13 3.3424685053647269.3541875183234A 14 2.70345650675251111.307639403626A 15 4.00616663408449124.004258887019A 16 5.1806910416212 128.613638097411A 17 -6.26534533776664 -0.944438526313875 A 18 -3.78598472716979 2.03694726901381A 19 -4.21383059434262.33837780519899A 20 1.8936558564966421.6366580986433A 21 4.5840279115829167.5861096660383A 22 2.05571359621679107.949510371836A 23 4.05242444227599112.126993688471A 24 4.34316209268166116.153400981747A 25 -2.12763929077743 -1.08663195011827 A 26 -2.10662282720267 -0.426141043811507 A 27 -3.01995286978557 -1.10752325011792 A 28 -1.64834644316891 7.78787375907454A 29 1.2440114496483745.3160993898581A 30 4.0353582382757787.1430284366417A 31 1.29543626134492105.003743707372A 32 3.84919041637386108.601951968250A 33 -3.2442183465 -0.382454625559666 A 34 -1.37712133953019 0.300186521658450 A 35 -2.12844632825254 -0.814335902708673 A 36 1.373118028256679.791747074437 A 37 -0.393168361803423 52.1011610030969A 38 2.66057348869074101.966194385881A 39 1.91384920016281112.592562878277A 40 2.06188667920977117.376424285145A 41 -3.05678162571978 -0.483215996703479 A 42 -0.184239995971267 1.23596224758922A 43 -1.42855399915072 0.248774451716021 A 44 1.4984400060720517.8847352593804A 45 2.5354258682307960.0336036447702A 46 2.95329003854665102.482588510080A 47 5.0685809676014 110.619630044398A 48 4.06642471090290120.486184775892A 49 -0.503130553392357 0.702688068466441 A 50 -0.860471679766733 1.43490186430460A 51 -0.17788663078253 3.11150418059122A 52 0.986266958945663 17.0902837098301A 53 2.1938933814974557.8826565905442A 54 3.9258915764087198.2558014383485A 55 2.53121102711589108.302821306135A 56 2.34432932634521111.053272678522A 97 -3.42191838986702 -0.885224809610779 A 98 -1.59014967363784 0.109987040681714 A 99 -1.58111592784537 3.78759624156396A 100 0.975980130414523 21.9589171041898A 101 2.6572303639741463.3950961679038A 102 3.3921352446590793.1009307560951A 103 4.2956847168814499.8712158796281A 104 4.84074935161124100.052602454596A 121 -1.68332987752984 0.227299766484946 A 122 0.468472823690819 1.87223738102554A 123 -0.547570024002551 4.37927291184889A 124 0.224584723010114 28.1273391056646A 125 1.9501827239534178.8401126239697
Re: [R] xyplot help
Thank you for pointing out panel.superpose. I got it working with panel.xyplot as below: xyplot(y~x,groups=type,plotdata, auto.key=list(space='bottom',points=T) , panel = function(x,y,subscripts, groups) { panel.xyplot(x,y, col=groups[subscripts]) x-sort(x) panel.lines(x,-1.324+0.1117*x-0.0006357*x*x) }) type='b' doesn't give me a smooth line, so it didn't produce what I want. Thanks John - Original Message From: Bert Gunter gunter.ber...@gene.com To: array chip arrayprof...@yahoo.com; r-help@r-project.org Sent: Thu, July 8, 2010 4:25:51 PM Subject: RE: [R] xyplot help Read the panel part of ?xyplot carefully and note ?panel.superpose. Typically, when you have a groups argument your panel function must be of the form panel = function(x,y,...){ panel.superpose(x,y,...) etc. } However, I think it might all happen automagically if you do the call as: xyplot(y~x,groups=type,plotdata, type = b, auto.key=T) This is also referenced in the panel section of the xyplot help, where you are referred to ?panel.xyplot for info on the type argument. So, in brief, read the docs more carefully. Bert Gunter Genentech Nonclinical Statistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of array chip Sent: Thursday, July 08, 2010 3:58 PM To: r-help@r-project.org Subject: [R] xyplot help Hi, I am learning xyplot. I have an example dataset attached. plotdata-read.table(plotdata.txt,sep='\t',header=T,row.names=1) head(plotdata,n=4) y x type 1 -4.309601 -0.7448405A 2 -4.715421 0.7875994A 3 -2.310638 0.5455310A 4 -2.685803 10.4116868A xyplot(y~x,groups=type,plotdata, auto.key=T) This shows different colors for different levels of type. Now, I want to add a fitted line to the plot, the formula is -1.324+0.1117*x-0.0006357*x*x I tried the following code to do this: xyplot(y~x,groups=type,plotdata, auto.key=T , panel = function(x,y) { panel.xyplot(x,y, type='p') x-sort(x) panel.lines(x,-1.324+0.1117*x-0.0006357*x*x) }) Now, it doesn't show different colors for different levels of type. How can I restore that? Also, is there anyway to put the legend at bottom of the plot (instead at the top right now)? And is there anyway to print legend horizontally, instead of vertically as shown right now? Thanks John __ 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.
Re: [R] xyplot - help with multiple Y's vs. X of a member data in multiple panels
Thanks for your email.. Yes, I am looking for lattice version of matplot... Attached are some codes for simplicity for rapid testing..Any suggestions would be highly appreciated... library(lattice) dat - data.frame(x = rep(1:10,2), y1 = rnorm(20), y2=rnorm(20,sd=1.3), y3=rnorm(20,sd=0.3), gp1 = rep(letters[1:8],each=10), gp2=rep(LETTERS[1:4],each=20), gp3=rep(c(P,Q),each=40)) pset - simpleTheme(lty = c(0,1,2), col=c(blue,red,green)) xyplot(y1+y2+y3~x|factor(gp3)+factor(gp2), data=dat, groups=gp1, allow.multiple=T, panel=panel.superpose, distribute.type=T, type=c(b,l,l), par.settings=pset, strip=strip.custom(strip.names=F,strip.levels=T)) Thanks.. Santosh On Mon, Jan 4, 2010 at 11:16 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: I think Santosh wants a Lattice version of matplot. I didn't find anything with help.search(), though... Dennis On Mon, Jan 4, 2010 at 8:14 PM, Santosh santosh2...@gmail.com wrote: Hi, Thanks for your email.. Each panel (in a multiple panel) is identified by DS1, DS2 DS3 in the dataset sent earlier. I would like an overlay of Y1, Y2 Y3 (each by different lines) for each ID in the group. Each ID in the group is represented by a color. Regards Thanks, Santosh On Mon, Jan 4, 2010 at 5:07 PM, Peter Ehlers ehl...@ucalgary.ca wrote: Can you clarify how many curves you want in each panel? You have 3 Ys and your original email indicated at least 7 ID values. Do you really want 21 curves in each panel? Or do you want separate panels for the Ys? Re your code: note that, regarding a formula of the type y1 + y2 ~ x, ?xyplot says: This feature cannot be used in conjunction with the groups argument. -Peter Ehlers Santosh wrote: Hi Jim and others, I tried suggestions and somehow the graphs do not seem to be aligned on X-axis (i.e. they appear to be shifted on x-axis).. I guess panel.xyplot or panel.superpose is needed? I am not sure what the group variable be panel.xyplot, whether it is the ID or the newFactor. I tried panel.xyplot(x,y,) with group=ID and group=newFactor and it did not work. Your suggestions would be highly appreciated!! Regards, Santosh On Thu, Dec 31, 2009 at 6:59 PM, jim holtman jholt...@gmail.com wrote: I am not too sure if this is what you are after, but I just created a new factor for the panel: # create a new factor d1$newFactor - factor(paste(d1$DS1, +, d1$DS2, +, d1$DS3)) xyplot(Y1+Y2+Y3~X1|newFactor,data=d1,group=ID) On Thu, Dec 31, 2009 at 6:25 AM, Santosh santosh2...@gmail.com wrote: Dear R experts, Wish you all a HAPPY NEW YEAR! How do I go about plotting (using lattice) overlays of an ID (group=ID) observed, fitted data in each panel of a multiple panel plot (each panel identified by DS1 + DS2 + DS3)? x variable is X1 in the accompanying section of a dataset. each individual is identified by color and Y's are identified by pch or lty. I guess the code goes something like the one below, but could not get the proper use of panel functions xyplot(Y1+Y2+Y3~X1|DS1+DS2+DS3,data=d1,group=ID,...)... [[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 http://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[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. -- Peter Ehlers University of Calgary 403.202.3921 [[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. [[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.
Re: [R] xyplot - help with multiple Y's vs. X of a member data in multiple panels
You should reshape the data into a long format, and an easy way to do that is to use the 'reshape' package: library(reshape) mdat - melt(dat, measure.vars = c(y1, y2, y3)) I'm still not sure what you want in the plot. Confusingly, your last example dropped the ID you referred to earlier, and appears to use grp1 in the same role. Maybe something like this: xyplot(value ~ x | paste(gp2, gp3), mdat, groups = paste(variable, gp1), type = l, auto.key = list(lines = TRUE, columns = 3), par.settings = simpleTheme(col = 1:8, lty = rep(1:3, each = 8))) 2010/1/5 Santosh santosh2...@gmail.com: Thanks for your email.. Yes, I am looking for lattice version of matplot... Attached are some codes for simplicity for rapid testing..Any suggestions would be highly appreciated... library(lattice) dat - data.frame(x = rep(1:10,2), y1 = rnorm(20), y2=rnorm(20,sd=1.3), y3=rnorm(20,sd=0.3), gp1 = rep(letters[1:8],each=10), gp2=rep(LETTERS[1:4],each=20), gp3=rep(c(P,Q),each=40)) pset - simpleTheme(lty = c(0,1,2), col=c(blue,red,green)) xyplot(y1+y2+y3~x|factor(gp3)+factor(gp2), data=dat, groups=gp1, allow.multiple=T, panel=panel.superpose, distribute.type=T, type=c(b,l,l), par.settings=pset, strip=strip.custom(strip.names=F,strip.levels=T)) Thanks.. Santosh On Mon, Jan 4, 2010 at 11:16 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: I think Santosh wants a Lattice version of matplot. I didn't find anything with help.search(), though... Dennis On Mon, Jan 4, 2010 at 8:14 PM, Santosh santosh2...@gmail.com wrote: Hi, Thanks for your email.. Each panel (in a multiple panel) is identified by DS1, DS2 DS3 in the dataset sent earlier. I would like an overlay of Y1, Y2 Y3 (each by different lines) for each ID in the group. Each ID in the group is represented by a color. Regards Thanks, Santosh On Mon, Jan 4, 2010 at 5:07 PM, Peter Ehlers ehl...@ucalgary.ca wrote: Can you clarify how many curves you want in each panel? You have 3 Ys and your original email indicated at least 7 ID values. Do you really want 21 curves in each panel? Or do you want separate panels for the Ys? Re your code: note that, regarding a formula of the type y1 + y2 ~ x, ?xyplot says: This feature cannot be used in conjunction with the groups argument. -Peter Ehlers Santosh wrote: Hi Jim and others, I tried suggestions and somehow the graphs do not seem to be aligned on X-axis (i.e. they appear to be shifted on x-axis).. I guess panel.xyplot or panel.superpose is needed? I am not sure what the group variable be panel.xyplot, whether it is the ID or the newFactor. I tried panel.xyplot(x,y,) with group=ID and group=newFactor and it did not work. Your suggestions would be highly appreciated!! Regards, Santosh On Thu, Dec 31, 2009 at 6:59 PM, jim holtman jholt...@gmail.com wrote: I am not too sure if this is what you are after, but I just created a new factor for the panel: # create a new factor d1$newFactor - factor(paste(d1$DS1, +, d1$DS2, +, d1$DS3)) xyplot(Y1+Y2+Y3~X1|newFactor,data=d1,group=ID) On Thu, Dec 31, 2009 at 6:25 AM, Santosh santosh2...@gmail.com wrote: Dear R experts, Wish you all a HAPPY NEW YEAR! How do I go about plotting (using lattice) overlays of an ID (group=ID) observed, fitted data in each panel of a multiple panel plot (each panel identified by DS1 + DS2 + DS3)? x variable is X1 in the accompanying section of a dataset. each individual is identified by color and Y's are identified by pch or lty. I guess the code goes something like the one below, but could not get the proper use of panel functions xyplot(Y1+Y2+Y3~X1|DS1+DS2+DS3,data=d1,group=ID,...)... [[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 http://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[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. -- Peter Ehlers University of Calgary 403.202.3921 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list
Re: [R] xyplot - help with multiple Y's vs. X of a member data in multiple panels
Hi.. thanks for the tips.. that variation works. How can I control pch, lty and col for each member (gp1) in the group (paste(gp2, gp3))? Regards,Santosh On Tue, Jan 5, 2010 at 2:15 AM, Felix Andrews fe...@nfrac.org wrote: You should reshape the data into a long format, and an easy way to do that is to use the 'reshape' package: library(reshape) mdat - melt(dat, measure.vars = c(y1, y2, y3)) I'm still not sure what you want in the plot. Confusingly, your last example dropped the ID you referred to earlier, and appears to use grp1 in the same role. Maybe something like this: xyplot(value ~ x | paste(gp2, gp3), mdat, groups = paste(variable, gp1), type = l, auto.key = list(lines = TRUE, columns = 3), par.settings = simpleTheme(col = 1:8, lty = rep(1:3, each = 8))) 2010/1/5 Santosh santosh2...@gmail.com: Thanks for your email.. Yes, I am looking for lattice version of matplot... Attached are some codes for simplicity for rapid testing..Any suggestions would be highly appreciated... library(lattice) dat - data.frame(x = rep(1:10,2), y1 = rnorm(20), y2=rnorm(20,sd=1.3), y3=rnorm(20,sd=0.3), gp1 = rep(letters[1:8],each=10), gp2=rep(LETTERS[1:4],each=20), gp3=rep(c(P,Q),each=40)) pset - simpleTheme(lty = c(0,1,2), col=c(blue,red,green)) xyplot(y1+y2+y3~x|factor(gp3)+factor(gp2), data=dat, groups=gp1, allow.multiple=T, panel=panel.superpose, distribute.type=T, type=c(b,l,l), par.settings=pset, strip=strip.custom(strip.names=F,strip.levels=T)) Thanks.. Santosh On Mon, Jan 4, 2010 at 11:16 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: I think Santosh wants a Lattice version of matplot. I didn't find anything with help.search(), though... Dennis On Mon, Jan 4, 2010 at 8:14 PM, Santosh santosh2...@gmail.com wrote: Hi, Thanks for your email.. Each panel (in a multiple panel) is identified by DS1, DS2 DS3 in the dataset sent earlier. I would like an overlay of Y1, Y2 Y3 (each by different lines) for each ID in the group. Each ID in the group is represented by a color. Regards Thanks, Santosh On Mon, Jan 4, 2010 at 5:07 PM, Peter Ehlers ehl...@ucalgary.ca wrote: Can you clarify how many curves you want in each panel? You have 3 Ys and your original email indicated at least 7 ID values. Do you really want 21 curves in each panel? Or do you want separate panels for the Ys? Re your code: note that, regarding a formula of the type y1 + y2 ~ x, ?xyplot says: This feature cannot be used in conjunction with the groups argument. -Peter Ehlers Santosh wrote: Hi Jim and others, I tried suggestions and somehow the graphs do not seem to be aligned on X-axis (i.e. they appear to be shifted on x-axis).. I guess panel.xyplot or panel.superpose is needed? I am not sure what the group variable be panel.xyplot, whether it is the ID or the newFactor. I tried panel.xyplot(x,y,) with group=ID and group=newFactor and it did not work. Your suggestions would be highly appreciated!! Regards, Santosh On Thu, Dec 31, 2009 at 6:59 PM, jim holtman jholt...@gmail.com wrote: I am not too sure if this is what you are after, but I just created a new factor for the panel: # create a new factor d1$newFactor - factor(paste(d1$DS1, +, d1$DS2, +, d1$DS3)) xyplot(Y1+Y2+Y3~X1|newFactor,data=d1,group=ID) On Thu, Dec 31, 2009 at 6:25 AM, Santosh santosh2...@gmail.com wrote: Dear R experts, Wish you all a HAPPY NEW YEAR! How do I go about plotting (using lattice) overlays of an ID (group=ID) observed, fitted data in each panel of a multiple panel plot (each panel identified by DS1 + DS2 + DS3)? x variable is X1 in the accompanying section of a dataset. each individual is identified by color and Y's are identified by pch or lty. I guess the code goes something like the one below, but could not get the proper use of panel functions xyplot(Y1+Y2+Y3~X1|DS1+DS2+DS3,data=d1,group=ID,...)... [[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 http://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list
Re: [R] xyplot - help with multiple Y's vs. X of a member data in multiple panels
Hi Jim and others, I tried suggestions and somehow the graphs do not seem to be aligned on X-axis (i.e. they appear to be shifted on x-axis).. I guess panel.xyplot or panel.superpose is needed? I am not sure what the group variable be panel.xyplot, whether it is the ID or the newFactor. I tried panel.xyplot(x,y,) with group=ID and group=newFactor and it did not work. Your suggestions would be highly appreciated!! Regards, Santosh On Thu, Dec 31, 2009 at 6:59 PM, jim holtman jholt...@gmail.com wrote: I am not too sure if this is what you are after, but I just created a new factor for the panel: # create a new factor d1$newFactor - factor(paste(d1$DS1, +, d1$DS2, +, d1$DS3)) xyplot(Y1+Y2+Y3~X1|newFactor,data=d1,group=ID) On Thu, Dec 31, 2009 at 6:25 AM, Santosh santosh2...@gmail.com wrote: Dear R experts, Wish you all a HAPPY NEW YEAR! How do I go about plotting (using lattice) overlays of an ID (group=ID) observed, fitted data in each panel of a multiple panel plot (each panel identified by DS1 + DS2 + DS3)? x variable is X1 in the accompanying section of a dataset. each individual is identified by color and Y's are identified by pch or lty. I guess the code goes something like the one below, but could not get the proper use of panel functions xyplot(Y1+Y2+Y3~X1|DS1+DS2+DS3,data=d1,group=ID,...)... [[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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[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.
Re: [R] xyplot - help with multiple Y's vs. X of a member data in multiple panels
Can you clarify how many curves you want in each panel? You have 3 Ys and your original email indicated at least 7 ID values. Do you really want 21 curves in each panel? Or do you want separate panels for the Ys? Re your code: note that, regarding a formula of the type y1 + y2 ~ x, ?xyplot says: This feature cannot be used in conjunction with the groups argument. -Peter Ehlers Santosh wrote: Hi Jim and others, I tried suggestions and somehow the graphs do not seem to be aligned on X-axis (i.e. they appear to be shifted on x-axis).. I guess panel.xyplot or panel.superpose is needed? I am not sure what the group variable be panel.xyplot, whether it is the ID or the newFactor. I tried panel.xyplot(x,y,) with group=ID and group=newFactor and it did not work. Your suggestions would be highly appreciated!! Regards, Santosh On Thu, Dec 31, 2009 at 6:59 PM, jim holtman jholt...@gmail.com wrote: I am not too sure if this is what you are after, but I just created a new factor for the panel: # create a new factor d1$newFactor - factor(paste(d1$DS1, +, d1$DS2, +, d1$DS3)) xyplot(Y1+Y2+Y3~X1|newFactor,data=d1,group=ID) On Thu, Dec 31, 2009 at 6:25 AM, Santosh santosh2...@gmail.com wrote: Dear R experts, Wish you all a HAPPY NEW YEAR! How do I go about plotting (using lattice) overlays of an ID (group=ID) observed, fitted data in each panel of a multiple panel plot (each panel identified by DS1 + DS2 + DS3)? x variable is X1 in the accompanying section of a dataset. each individual is identified by color and Y's are identified by pch or lty. I guess the code goes something like the one below, but could not get the proper use of panel functions xyplot(Y1+Y2+Y3~X1|DS1+DS2+DS3,data=d1,group=ID,...)... [[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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[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. -- Peter Ehlers University of Calgary 403.202.3921 __ 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.
Re: [R] xyplot - help with multiple Y's vs. X of a member data in multiple panels
Hi, Thanks for your email.. Each panel (in a multiple panel) is identified by DS1, DS2 DS3 in the dataset sent earlier. I would like an overlay of Y1, Y2 Y3 (each by different lines) for each ID in the group. Each ID in the group is represented by a color. Regards Thanks, Santosh On Mon, Jan 4, 2010 at 5:07 PM, Peter Ehlers ehl...@ucalgary.ca wrote: Can you clarify how many curves you want in each panel? You have 3 Ys and your original email indicated at least 7 ID values. Do you really want 21 curves in each panel? Or do you want separate panels for the Ys? Re your code: note that, regarding a formula of the type y1 + y2 ~ x, ?xyplot says: This feature cannot be used in conjunction with the groups argument. -Peter Ehlers Santosh wrote: Hi Jim and others, I tried suggestions and somehow the graphs do not seem to be aligned on X-axis (i.e. they appear to be shifted on x-axis).. I guess panel.xyplot or panel.superpose is needed? I am not sure what the group variable be panel.xyplot, whether it is the ID or the newFactor. I tried panel.xyplot(x,y,) with group=ID and group=newFactor and it did not work. Your suggestions would be highly appreciated!! Regards, Santosh On Thu, Dec 31, 2009 at 6:59 PM, jim holtman jholt...@gmail.com wrote: I am not too sure if this is what you are after, but I just created a new factor for the panel: # create a new factor d1$newFactor - factor(paste(d1$DS1, +, d1$DS2, +, d1$DS3)) xyplot(Y1+Y2+Y3~X1|newFactor,data=d1,group=ID) On Thu, Dec 31, 2009 at 6:25 AM, Santosh santosh2...@gmail.com wrote: Dear R experts, Wish you all a HAPPY NEW YEAR! How do I go about plotting (using lattice) overlays of an ID (group=ID) observed, fitted data in each panel of a multiple panel plot (each panel identified by DS1 + DS2 + DS3)? x variable is X1 in the accompanying section of a dataset. each individual is identified by color and Y's are identified by pch or lty. I guess the code goes something like the one below, but could not get the proper use of panel functions xyplot(Y1+Y2+Y3~X1|DS1+DS2+DS3,data=d1,group=ID,...)... [[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 http://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[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. -- Peter Ehlers University of Calgary 403.202.3921 [[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.
Re: [R] xyplot - help with multiple Y's vs. X of a member data in multiple panels
Hi I missed the earlier emails and I am not too sure of what you want but have a look at requiire(latticeExtra) ? useOuterStrips It may improve the layout and readability Duncan Mackay Department of Agronomy and Soil Science University of New England ARMIDALE NSW 2351 Email Home: mac...@northnet.com.au At 14:14 5/01/2010, you wrote: Hi, Thanks for your email.. Each panel (in a multiple panel) is identified by DS1, DS2 DS3 in the dataset sent earlier. I would like an overlay of Y1, Y2 Y3 (each by different lines) for each ID in the group. Each ID in the group is represented by a color. Regards Thanks, Santosh On Mon, Jan 4, 2010 at 5:07 PM, Peter Ehlers ehl...@ucalgary.ca wrote: Can you clarify how many curves you want in each panel? You have 3 Ys and your original email indicated at least 7 ID values. Do you really want 21 curves in each panel? Or do you want separate panels for the Ys? Re your code: note that, regarding a formula of the type y1 + y2 ~ x, ?xyplot says: This feature cannot be used in conjunction with the groups argument. -Peter Ehlers Santosh wrote: Hi Jim and others, I tried suggestions and somehow the graphs do not seem to be aligned on X-axis (i.e. they appear to be shifted on x-axis).. I guess panel.xyplot or panel.superpose is needed? I am not sure what the group variable be panel.xyplot, whether it is the ID or the newFactor. I tried panel.xyplot(x,y,) with group=ID and group=newFactor and it did not work. Your suggestions would be highly appreciated!! Regards, Santosh On Thu, Dec 31, 2009 at 6:59 PM, jim holtman jholt...@gmail.com wrote: I am not too sure if this is what you are after, but I just created a new factor for the panel: # create a new factor d1$newFactor - factor(paste(d1$DS1, +, d1$DS2, +, d1$DS3)) xyplot(Y1+Y2+Y3~X1|newFactor,data=d1,group=ID) On Thu, Dec 31, 2009 at 6:25 AM, Santosh santosh2...@gmail.com wrote: Dear R experts, Wish you all a HAPPY NEW YEAR! How do I go about plotting (using lattice) overlays of an ID (group=ID) observed, fitted data in each panel of a multiple panel plot (each panel identified by DS1 + DS2 + DS3)? x variable is X1 in the accompanying section of a dataset. each individual is identified by color and Y's are identified by pch or lty. I guess the code goes something like the one below, but could not get the proper use of panel functions xyplot(Y1+Y2+Y3~X1|DS1+DS2+DS3,data=d1,group=ID,...)... [[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 http://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[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. -- Peter Ehlers University of Calgary 403.202.3921 [[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. __ 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.
Re: [R] xyplot - help with multiple Y's vs. X of a member data in multiple panels
Hi: I think Santosh wants a Lattice version of matplot. I didn't find anything with help.search(), though... Dennis On Mon, Jan 4, 2010 at 8:14 PM, Santosh santosh2...@gmail.com wrote: Hi, Thanks for your email.. Each panel (in a multiple panel) is identified by DS1, DS2 DS3 in the dataset sent earlier. I would like an overlay of Y1, Y2 Y3 (each by different lines) for each ID in the group. Each ID in the group is represented by a color. Regards Thanks, Santosh On Mon, Jan 4, 2010 at 5:07 PM, Peter Ehlers ehl...@ucalgary.ca wrote: Can you clarify how many curves you want in each panel? You have 3 Ys and your original email indicated at least 7 ID values. Do you really want 21 curves in each panel? Or do you want separate panels for the Ys? Re your code: note that, regarding a formula of the type y1 + y2 ~ x, ?xyplot says: This feature cannot be used in conjunction with the groups argument. -Peter Ehlers Santosh wrote: Hi Jim and others, I tried suggestions and somehow the graphs do not seem to be aligned on X-axis (i.e. they appear to be shifted on x-axis).. I guess panel.xyplot or panel.superpose is needed? I am not sure what the group variable be panel.xyplot, whether it is the ID or the newFactor. I tried panel.xyplot(x,y,) with group=ID and group=newFactor and it did not work. Your suggestions would be highly appreciated!! Regards, Santosh On Thu, Dec 31, 2009 at 6:59 PM, jim holtman jholt...@gmail.com wrote: I am not too sure if this is what you are after, but I just created a new factor for the panel: # create a new factor d1$newFactor - factor(paste(d1$DS1, +, d1$DS2, +, d1$DS3)) xyplot(Y1+Y2+Y3~X1|newFactor,data=d1,group=ID) On Thu, Dec 31, 2009 at 6:25 AM, Santosh santosh2...@gmail.com wrote: Dear R experts, Wish you all a HAPPY NEW YEAR! How do I go about plotting (using lattice) overlays of an ID (group=ID) observed, fitted data in each panel of a multiple panel plot (each panel identified by DS1 + DS2 + DS3)? x variable is X1 in the accompanying section of a dataset. each individual is identified by color and Y's are identified by pch or lty. I guess the code goes something like the one below, but could not get the proper use of panel functions xyplot(Y1+Y2+Y3~X1|DS1+DS2+DS3,data=d1,group=ID,...)... [[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 http://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[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. -- Peter Ehlers University of Calgary 403.202.3921 [[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. [[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.
[R] xyplot - help with multiple Y's vs. X of a member data in multiple panels
Dear R experts, Wish you all a HAPPY NEW YEAR! How do I go about plotting (using lattice) overlays of an ID (group=ID) observed, fitted data in each panel of a multiple panel plot (each panel identified by DS1 + DS2 + DS3)? x variable is X1 in the accompanying section of a dataset. each individual is identified by color and Y's are identified by pch or lty. I guess the code goes something like the one below, but could not get the proper use of panel functions xyplot(Y1+Y2+Y3~X1|DS1+DS2+DS3,data=d1,group=ID,...) A sample section of the data is given below.. DS3,DS2,DS1,ID,X1,TYPE,Y1,Y2,Y3 1,1,1,1,6.087,1,1.81,1.64,1.82 1,1,1,1,6.337,1,2.61,2.48,2.56 1,1,1,1,6.837,1,3.14,3.10,3.08 1,1,1,1,7.837,1,3.39,3.50,3.36 1,1,1,1,8.837,1,3.34,3.62,3.39 1,1,1,1,9.837,1,3.27,3.63,3.34 1,1,1,1,10.837,1,3.25,3.59,3.25 1,1,1,1,12.862,1,2.96,3.44,3.04 1,1,1,1,15.837,1,2.72,3.15,2.68 1,1,1,1,19.844,1,2.21,2.69,2.18 1,1,1,1,26.837,1,1.29,1.79,1.28 1,1,1,1,33.858,1,0.40,0.88,0.41 1,1,1,1,40.886,1,-0.43,0.03,-0.41 1,0.1,1,2,8.092,1,0.03,-0.67,0.04 1,0.1,1,2,8.342,1,0.78,0.14,0.57 1,0.1,1,2,8.842,1,0.90,0.71,0.84 1,0.1,1,2,9.842,1,0.79,1.00,0.84 1,0.1,1,2,10.842,1,0.76,1.02,0.73 1,0.1,1,2,11.842,1,0.45,0.95,0.60 1,0.1,1,2,12.842,1,0.37,0.86,0.48 1,0.1,1,2,14.873,1,0.07,0.63,0.24 1,0.1,1,2,17.842,1,-0.21,0.29,-0.10 1,0.1,1,2,21.842,1,-0.17,-0.15,-0.52 1,0.1,1,3,7.208,1,-0.22,-0.77,-0.15 1,0.1,1,3,7.458,1,0.70,0.03,0.53 1,0.1,1,3,7.958,1,0.98,0.60,0.90 1,0.1,1,3,8.958,1,0.83,0.89,0.93 1,0.1,1,3,9.958,1,0.73,0.91,0.79 1,0.1,1,3,10.958,1,0.65,0.84,0.63 1,0.1,1,3,11.958,1,0.37,0.75,0.46 1,0.1,1,3,13.958,1,0.26,0.53,0.14 1,0.1,1,3,16.958,1,-0.34,0.19,-0.32 1,0.1,1,4,7.305,1,-1.09,0.24,-1.16 1,0.1,1,4,7.805,1,-0.61,0.80,-0.44 1,0.1,1,4,8.805,1,-0.03,1.10,0.04 1,0.1,1,4,9.805,1,0.14,1.12,0.20 1,0.1,1,4,10.805,1,0.26,1.05,0.25 1,0.1,1,4,11.805,1,0.28,0.96,0.25 1,0.1,1,4,13.817,1,0.30,0.73,0.18 1,0.1,1,4,16.805,1,0.10,0.39,-0.01 1,0.1,1,4,20.805,1,-0.47,-0.06,-0.31 1,0.1,1,5,8.307,1,-0.36,0.03,-0.48 1,0.1,1,5,8.807,1,-0.17,0.60,-0.02 1,0.1,1,5,9.807,1,0.05,0.89,0.17 1,0.1,1,5,10.807,1,0.18,0.91,0.14 1,0.1,1,5,11.807,1,0.03,0.84,0.06 1,0.1,1,5,12.807,1,0.10,0.75,-0.04 1,0.1,1,5,14.817,1,-0.28,0.53,-0.26 0,0.1,1,5,17.807,1,-0.65,0.19,-0.60 0,0.1,1,6,6.133,1,-0.41,-0.67,-0.42 0,0.1,1,6,6.383,1,0.41,0.14,0.55 0,0.1,1,6,6.883,1,1.36,0.71,1.21 0,0.1,1,6,7.883,1,1.52,1.00,1.44 0,0.1,1,6,8.883,1,1.40,1.02,1.33 0,0.1,1,6,9.883,1,1.05,0.95,1.12 0,0.1,1,6,10.883,1,0.91,0.86,0.89 0,0.1,1,6,12.89,1,0.42,0.63,0.44 0,0.1,1,6,15.883,1,-0.19,0.29,-0.14 1,5,1,7,9.983,1,3.27,3.02,3.20 1,5,1,7,10.233,1,3.94,3.88,3.87 1,5,1,7,10.733,1,4.35,4.54,4.40 1,5,1,7,11.733,1,4.68,5.00,4.76 1,5,1,7,12.733,1,4.87,5.16,4.87 1,5,1,7,13.733,1,4.80,5.21,4.91 1,5,1,7,14.733,1,4.97,5.22,4.92 1,5,1,7,16.733,1,4.87,5.16,4.90 1,5,1,7,19.754,1,4.72,5.02,4.82 1,5,1,7,23.733,1,4.67,4.78,4.68 1,5,1,7,30.733,1,4.31,4.29,4.35 1,5,1,7,37.733,1,4.01,3.68,3.90 1,5,1,7,44.733,1,3.40,2.92,3.31 1,5,1,7,51.749,1,2.53,2.01,2.52 1,5,1,7,58.733,1,1.57,1.10,1.57 1,5,1,7,65.733,1,0.54,0.23,0.62 1,5,1,7,72.733,1,-0.23,-0.54,-0.24 1,5,1,7,79.733,1,-1.03,-1.14,-0.94 Please let me know if you need additional info. Thanks, Santosh [[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.
Re: [R] xyplot - help with multiple Y's vs. X of a member data in multiple panels
I am not too sure if this is what you are after, but I just created a new factor for the panel: # create a new factor d1$newFactor - factor(paste(d1$DS1, +, d1$DS2, +, d1$DS3)) xyplot(Y1+Y2+Y3~X1|newFactor,data=d1,group=ID) On Thu, Dec 31, 2009 at 6:25 AM, Santosh santosh2...@gmail.com wrote: Dear R experts, Wish you all a HAPPY NEW YEAR! How do I go about plotting (using lattice) overlays of an ID (group=ID) observed, fitted data in each panel of a multiple panel plot (each panel identified by DS1 + DS2 + DS3)? x variable is X1 in the accompanying section of a dataset. each individual is identified by color and Y's are identified by pch or lty. I guess the code goes something like the one below, but could not get the proper use of panel functions xyplot(Y1+Y2+Y3~X1|DS1+DS2+DS3,data=d1,group=ID,...) A sample section of the data is given below.. DS3,DS2,DS1,ID,X1,TYPE,Y1,Y2,Y3 1,1,1,1,6.087,1,1.81,1.64,1.82 1,1,1,1,6.337,1,2.61,2.48,2.56 1,1,1,1,6.837,1,3.14,3.10,3.08 1,1,1,1,7.837,1,3.39,3.50,3.36 1,1,1,1,8.837,1,3.34,3.62,3.39 1,1,1,1,9.837,1,3.27,3.63,3.34 1,1,1,1,10.837,1,3.25,3.59,3.25 1,1,1,1,12.862,1,2.96,3.44,3.04 1,1,1,1,15.837,1,2.72,3.15,2.68 1,1,1,1,19.844,1,2.21,2.69,2.18 1,1,1,1,26.837,1,1.29,1.79,1.28 1,1,1,1,33.858,1,0.40,0.88,0.41 1,1,1,1,40.886,1,-0.43,0.03,-0.41 1,0.1,1,2,8.092,1,0.03,-0.67,0.04 1,0.1,1,2,8.342,1,0.78,0.14,0.57 1,0.1,1,2,8.842,1,0.90,0.71,0.84 1,0.1,1,2,9.842,1,0.79,1.00,0.84 1,0.1,1,2,10.842,1,0.76,1.02,0.73 1,0.1,1,2,11.842,1,0.45,0.95,0.60 1,0.1,1,2,12.842,1,0.37,0.86,0.48 1,0.1,1,2,14.873,1,0.07,0.63,0.24 1,0.1,1,2,17.842,1,-0.21,0.29,-0.10 1,0.1,1,2,21.842,1,-0.17,-0.15,-0.52 1,0.1,1,3,7.208,1,-0.22,-0.77,-0.15 1,0.1,1,3,7.458,1,0.70,0.03,0.53 1,0.1,1,3,7.958,1,0.98,0.60,0.90 1,0.1,1,3,8.958,1,0.83,0.89,0.93 1,0.1,1,3,9.958,1,0.73,0.91,0.79 1,0.1,1,3,10.958,1,0.65,0.84,0.63 1,0.1,1,3,11.958,1,0.37,0.75,0.46 1,0.1,1,3,13.958,1,0.26,0.53,0.14 1,0.1,1,3,16.958,1,-0.34,0.19,-0.32 1,0.1,1,4,7.305,1,-1.09,0.24,-1.16 1,0.1,1,4,7.805,1,-0.61,0.80,-0.44 1,0.1,1,4,8.805,1,-0.03,1.10,0.04 1,0.1,1,4,9.805,1,0.14,1.12,0.20 1,0.1,1,4,10.805,1,0.26,1.05,0.25 1,0.1,1,4,11.805,1,0.28,0.96,0.25 1,0.1,1,4,13.817,1,0.30,0.73,0.18 1,0.1,1,4,16.805,1,0.10,0.39,-0.01 1,0.1,1,4,20.805,1,-0.47,-0.06,-0.31 1,0.1,1,5,8.307,1,-0.36,0.03,-0.48 1,0.1,1,5,8.807,1,-0.17,0.60,-0.02 1,0.1,1,5,9.807,1,0.05,0.89,0.17 1,0.1,1,5,10.807,1,0.18,0.91,0.14 1,0.1,1,5,11.807,1,0.03,0.84,0.06 1,0.1,1,5,12.807,1,0.10,0.75,-0.04 1,0.1,1,5,14.817,1,-0.28,0.53,-0.26 0,0.1,1,5,17.807,1,-0.65,0.19,-0.60 0,0.1,1,6,6.133,1,-0.41,-0.67,-0.42 0,0.1,1,6,6.383,1,0.41,0.14,0.55 0,0.1,1,6,6.883,1,1.36,0.71,1.21 0,0.1,1,6,7.883,1,1.52,1.00,1.44 0,0.1,1,6,8.883,1,1.40,1.02,1.33 0,0.1,1,6,9.883,1,1.05,0.95,1.12 0,0.1,1,6,10.883,1,0.91,0.86,0.89 0,0.1,1,6,12.89,1,0.42,0.63,0.44 0,0.1,1,6,15.883,1,-0.19,0.29,-0.14 1,5,1,7,9.983,1,3.27,3.02,3.20 1,5,1,7,10.233,1,3.94,3.88,3.87 1,5,1,7,10.733,1,4.35,4.54,4.40 1,5,1,7,11.733,1,4.68,5.00,4.76 1,5,1,7,12.733,1,4.87,5.16,4.87 1,5,1,7,13.733,1,4.80,5.21,4.91 1,5,1,7,14.733,1,4.97,5.22,4.92 1,5,1,7,16.733,1,4.87,5.16,4.90 1,5,1,7,19.754,1,4.72,5.02,4.82 1,5,1,7,23.733,1,4.67,4.78,4.68 1,5,1,7,30.733,1,4.31,4.29,4.35 1,5,1,7,37.733,1,4.01,3.68,3.90 1,5,1,7,44.733,1,3.40,2.92,3.31 1,5,1,7,51.749,1,2.53,2.01,2.52 1,5,1,7,58.733,1,1.57,1.10,1.57 1,5,1,7,65.733,1,0.54,0.23,0.62 1,5,1,7,72.733,1,-0.23,-0.54,-0.24 1,5,1,7,79.733,1,-1.03,-1.14,-0.94 Please let me know if you need additional info. Thanks, Santosh [[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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[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.
Re: [R] xyplot help - colors and break in plot
Felix, Thanks, that did the trick! Lattice is a lot less intuitive than basic plotting! Also, another person suggested using gap.plot from the plotrix package to put a break in the graph. I am surprised Lattice doesn't have something similar since it seems like a common problem when you have data that groups in clusters separated by a large range. Aloha, Tim Tim Clark Department of Zoology University of Hawaii --- On Mon, 9/28/09, Felix Andrews fe...@nfrac.org wrote: From: Felix Andrews fe...@nfrac.org Subject: Re: [R] xyplot help - colors and break in plot To: Tim Clark mudiver1...@yahoo.com Cc: r-help@r-project.org Date: Monday, September 28, 2009, 1:50 PM 2009/9/29 Tim Clark mudiver1...@yahoo.com: Dear List, I am new to lattice plots, and am having problems with getting my plot to do what I want. Specifically: 1. I would like the legend to have the same symbols as the plot. I tried simpleKey but can't seem to get it to work with autoKey. Right now my plot has dots (pch=19) and my legend shows circles. Rather than the pch = 19 argument, use par.settings = simpleTheme(pch = 19, cex = .4) 2. I have nine groups but xyplot seems to only be using seven colors, so two groups have the same color. How do I get a range of nine colors? Yes, in the default theme, there are seven colours: see trellis.par.get(superpose.symbol) You can change the set of colours yourself by modifying that list (via trellis.par.set). An easier option is to use one of the predefined ColorBrewer palettes, with custom.theme() from the latticeExtra package, or just simpleTheme(). See ?brewer.pal (RColorBrewer package) You will see there are a few qualitative color palettes with 9 or more colours: e.g. brewer.pal(9, Set1) brewer.pal(12, Set3) 3. I have one group who's y range is much greater than all the others. I would like to split the plot somehow so that the bottom part shows ylim=c(0,200) and the top shows ylim=c(450,550). Is this possible? Yes... in the absence of a reproducible example, maybe something like xyplot(Area.km2 ~ DataPoint | (Area.km2 200), m.dp.area, groups = Manta, scales = list(y = free)) or AreaRange - shingle(Area.km2, rbind(c(0,200),c(450,550))) xyplot(Area.km2 ~ DataPoint | AreaRange, m.dp.area, groups = Manta, scales = list(y = free)) What I have so far is: library(lattice) xyplot(m.dp.area$Area.km2 ~ m.dp.area$DataPoint, m.dp.area, groups = m.dp.area$Manta, main = Cummulative area of 100% MCP, xlab = Data Point, ylab = MCP Area, ylim = c(0,150), scales = list(tck = c(1, 0)), #Removes tics on top and r-axis pch=19,cex=.4, auto.key = list(title = Mantas, x = .05, y=.95, corner = c(0,1),border = TRUE)) #Legend Thanks, Tim Tim Clark Department of Zoology University of Hawaii __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 1670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
[R] xyplot help - colors and break in plot
Dear List, I am new to lattice plots, and am having problems with getting my plot to do what I want. Specifically: 1. I would like the legend to have the same symbols as the plot. I tried simpleKey but can't seem to get it to work with autoKey. Right now my plot has dots (pch=19) and my legend shows circles. 2. I have nine groups but xyplot seems to only be using seven colors, so two groups have the same color. How do I get a range of nine colors? 3. I have one group who's y range is much greater than all the others. I would like to split the plot somehow so that the bottom part shows ylim=c(0,200) and the top shows ylim=c(450,550). Is this possible? What I have so far is: library(lattice) xyplot(m.dp.area$Area.km2 ~ m.dp.area$DataPoint, m.dp.area, groups = m.dp.area$Manta, main = Cummulative area of 100% MCP, xlab = Data Point, ylab = MCP Area, ylim = c(0,150), scales = list(tck = c(1, 0)), #Removes tics on top and r-axis pch=19,cex=.4, auto.key = list(title = Mantas, x = .05, y=.95, corner = c(0,1),border = TRUE)) #Legend Thanks, Tim Tim Clark Department of Zoology University of Hawaii __ 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.
Re: [R] xyplot help - colors and break in plot
2009/9/29 Tim Clark mudiver1...@yahoo.com: Dear List, I am new to lattice plots, and am having problems with getting my plot to do what I want. Specifically: 1. I would like the legend to have the same symbols as the plot. I tried simpleKey but can't seem to get it to work with autoKey. Right now my plot has dots (pch=19) and my legend shows circles. Rather than the pch = 19 argument, use par.settings = simpleTheme(pch = 19, cex = .4) 2. I have nine groups but xyplot seems to only be using seven colors, so two groups have the same color. How do I get a range of nine colors? Yes, in the default theme, there are seven colours: see trellis.par.get(superpose.symbol) You can change the set of colours yourself by modifying that list (via trellis.par.set). An easier option is to use one of the predefined ColorBrewer palettes, with custom.theme() from the latticeExtra package, or just simpleTheme(). See ?brewer.pal (RColorBrewer package) You will see there are a few qualitative color palettes with 9 or more colours: e.g. brewer.pal(9, Set1) brewer.pal(12, Set3) 3. I have one group who's y range is much greater than all the others. I would like to split the plot somehow so that the bottom part shows ylim=c(0,200) and the top shows ylim=c(450,550). Is this possible? Yes... in the absence of a reproducible example, maybe something like xyplot(Area.km2 ~ DataPoint | (Area.km2 200), m.dp.area, groups = Manta, scales = list(y = free)) or AreaRange - shingle(Area.km2, rbind(c(0,200),c(450,550))) xyplot(Area.km2 ~ DataPoint | AreaRange, m.dp.area, groups = Manta, scales = list(y = free)) What I have so far is: library(lattice) xyplot(m.dp.area$Area.km2 ~ m.dp.area$DataPoint, m.dp.area, groups = m.dp.area$Manta, main = Cummulative area of 100% MCP, xlab = Data Point, ylab = MCP Area, ylim = c(0,150), scales = list(tck = c(1, 0)), #Removes tics on top and r-axis pch=19,cex=.4, auto.key = list(title = Mantas, x = .05, y=.95, corner = c(0,1),border = TRUE)) #Legend Thanks, Tim Tim Clark Department of Zoology University of Hawaii __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 1670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
[R] XYPLOT Help
This may be an easy question for most of you, but any prompt clues/hints/examples would be really appreciated. My dataset includes a various number of records (by time points) for a variable by subject. I use xyplot to plot line/symbol graphs of the variable at each available time point by each subject on the same plot (see attached as an example). How to suppress those symbols with no available time points (e.g. symbols for subject 1001 study days 5, 6, 7)? Below is a quick example of data: Subject Study Day% CD8 response 1001 1 0.23 1001 2 0.25 1001 3 0.27 1001 4 0.29 1001 8 0.29 1002 1 0.23 1002 2 0.25 1002 3 0.27 1002 4 0.29 1002 5 0.23 1002 6 0.25 1002 7 0.27 1002 8 0.29 1003 1 0.23 1003 2 0.25 1003 3 0.27 1003 4 0.29 1003 5 0.23 1003 6 0.25 1003 7 0.27 1003 8 0.29 1004 1 0.23 1004 2 0.25 1004 3 0.27 1004 4 0.29 1004 8 0.29 Thanks a lot in advance! James __ 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.
[R] xyplot help
I have a question about xyplot. Suppose I want to plot say a response variable y vs a predictor x within groups defined by a variable called z. And suppose I have another variable v=1,2 with two levels. I would use the following command to get a spaghetti plot with two panels defined by v. xyplot(y~x|v,groups=z,type=l) My question is that on top of the panels, the title of each panel would just say v. Suppose I want it to say v=1 for one panel and v=2 for the other. Can someone tell me how I would go about doing this? Thanks for your help. _ With Windows Live for mobile, your contacts travel with you. 072008 [[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.
Re: [R] xyplot help
v - factor(1:2) xyplot(1:2 ~ 1:2 | v, strip=strip.custom(strip.names=TRUE, sep==)) or v - shingle(1:2) xyplot(1:2 ~ 1:2 | v, strip=strip.custom(strip.levels=TRUE, sep==)) On Tue, Jul 22, 2008 at 4:26 PM, [EMAIL PROTECTED] wrote: I have a question about xyplot. Suppose I want to plot say a response variable y vs a predictor x within groups defined by a variable called z. And suppose I have another variable v=1,2 with two levels. I would use the following command to get a spaghetti plot with two panels defined by v. xyplot(y~x|v,groups=z,type=l) My question is that on top of the panels, the title of each panel would just say v. Suppose I want it to say v=1 for one panel and v=2 for the other. Can someone tell me how I would go about doing this? Thanks for your help. _ With Windows Live for mobile, your contacts travel with you. 072008 [[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. -- Felix Andrews / 安福立 PhD candidate Integrated Catchment Assessment and Management Centre The Fenner School of Environment and Society The Australian National University (Building 48A), ACT 0200 Beijing Bag, Locked Bag 40, Kingston ACT 2604 http://www.neurofractal.org/felix/ 3358 543D AAC6 22C2 D336 80D9 360B 72DD 3E4C F5D8 __ 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.