[R] "Groups" in XYPLOT

Andrew Robinson A.Robinson at ms.unimelb.edu.au
Sun Mar 18 04:14:34 CET 2007


Hi Thomas,

sadly, the full code is not much help to us in the absence of the
data.  Can I suggest that you construct a reproducible worked example
to help explain your question?  For what it's worth I suspect that the
answer is that you need to join these datasets into one and theneitehr
use the groups argument, or the "+" protocol on the LHS of the plot
formula.

Cheers

Andrew

On Tue, Mar 27, 2007 at 04:51:55PM -0500, Thomas Colson wrote:
> I'm not sure I'm barking up the right tree here, but would I need to make
> use of groups to plot two separate datasets within ONE panel in xyplot? The
> desired end result is a single xy plot of two separate (but similar in
> values and ranges). 
> 
> Full code follows, xyplot code at bottom
> 
> 
> 
> 
> 
> #########Determine Frequencies
> ##########coastal_slope
> #needs the maptools package to read ESRI grid
> require(maptools)
> #import the flow slope grid
> basin.map <- readAsciiGrid("C:/R_PLots/coastal_slp.asc", colname="slope")
> basin_slope <- (basin.map$slope)
> #read the slopes into a dataframe
> freqs<-as.data.frame(table(basin_slope))
> #rank the frequencies based on each unique occerence, note, ranks from 1 to
> n
> r<-rank(freqs$basin_slope)
> n<-length(r)
> #determing the probability, n+1 insures there is no 100%, 1- reverses the
> order so
> #low slopes gets high probability of exceedence
> z<-cbind(Rank = r, PRank = 1-(r/(n+1)))
> #attach the probability to the table, result is high prob of exceed is in
> row with low slope
> #and low probabibility is in row with high slope
> freqs$rank<-z
> write.table(freqs, "C:/R_PLots/coastslopefreqs.txt", sep=",",
> col.names=TRUE, row.names=TRUE, quote=TRUE, na="NA")
> 
> ##########coastal_curvature
> #needs the maptools package to read ESRI grid
> require(maptools)
> #import the curvature grid
> basin.map <- readAsciiGrid("C:/R_PLots/coastal_crv.asc", colname="curv")
> basin_curv <- (basin.map$curv)
> #read the curvs into a dataframe
> freqs<-as.data.frame(table(basin_curv))
> #rank the frequencies based on each unique occerence, note, ranks from 1 to
> n
> r<-rank(freqs$basin_curv)
> n<-length(r)
> #determing the probability, n+1 insures there is no 100%, 1- reverses the
> order so
> #low curvature gets high probability of exceedence
> z<-cbind(Rank = r, PRank = 1-(r/(n+1)))
> #attach the probability to the table, result is high prob of exceed is in
> row with low curv
> #and low probabibility is in row with high curv
> freqs$rank<-z
> write.table(freqs, "C:/R_PLots/coastcurvfreqs.txt", sep=",", col.names=TRUE,
> row.names=TRUE, quote=TRUE, na="NA")
> 
> 
> 
> 
> 
> ##############Make XYPLOT and export to ps
> coastcurv <- read.table("C:/R_PLots/coastcurvfreqs.txt", header=TRUE,
> sep=",", na.strings="NA", dec=".", strip.white=TRUE)
> xyplot(coastcurv$rank.PRank~coastcurv$basin_curv,scales=list(y=list(log=TRUE
> ,at=c(.0001,.001,.01,.1,1)),x=list(log=TRUE,at=c(0.0001,0.001,0.01,0.1,1,10)
> )),xlab="Curvature",ylab="P(C>C*)")
> dev.copy2eps(file="C:/R_PLots/coastcurv_cad.eps", width=8.0, height=8.0,
> pointsize=10)
> 
> 
> ########How to get this in the first plot graphic?
> 
> coastslope <- read.table("C:/R_PLots/coastslopefreqs.txt", header=TRUE,
> sep=",", na.strings="NA", dec=".", strip.white=TRUE)
> xyplot(coastslope$rank.PRank~coastslope$basin_slope,scales=list(y=list(log=T
> RUE,at=c(.0001,.001,.01,.1,1)),x=list(log=TRUE,at=c(0.0001,0.001,0.01,0.1,1,
> 10))),xlab="Slope",ylab="P(S>S*)")
> dev.copy2eps(file="C:/R_PLots/coastslope_cad.eps", width=8.0, height=8.0,
> pointsize=10)
> 
> Thomas Colson, PhD
> North Carolina State University
> Department of Forestry and Environmental Resources
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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.

-- 
Andrew Robinson  
Department of Mathematics and Statistics            Tel: +61-3-8344-9763
University of Melbourne, VIC 3010 Australia         Fax: +61-3-8344-4599
http://www.ms.unimelb.edu.au/~andrewpr
http://blogs.mbs.edu/fishing-in-the-bay/



More information about the R-help mailing list