i have three data, x coordinate, y coordinate and signal strength i use tapply() function to get the average ss in the give x,y location x=c(1,2,3,1) y=c(1,2,3,1) ss=c(55,NA,55,88) ss_byxy_test=tapply( ss, list( x, y), mean) and I get this table 1 2 3 1 71.5 NA NA 2 NA NA NA 3 NA NA 55 but i don't know how to plot different the ss with the xy location, can anyone help me -- View this message in context: http://n4.nabble.com/plot-data-from-tapply-tp949436p949436.html Sent from the R help mailing list archive at Nabble.com.
Here is one way of doing it: x=c(1,2,3,1) y=c(1,2,3,1) ss=c(55,NA,55,88) ss_byxy_test=tapply( ss, list( x, y), mean, na.rm=TRUE) # use the 'reshape' package ss_byxy_test # now 'melt' the data to get it into a format for plotting (ss_melt <- melt(ss_byxy_test)) # create the plot area so you can add the 'ss' as text plot(0, type='n', xlim=range(ss_melt$X1), ylim=range(ss_melt$X2), xlab="X", ylab="Y") text(ss_melt$X1, ss_melt$X2, ss_melt$value, font=2, col='red') On Sat, Dec 5, 2009 at 4:49 PM, dwwc <dwwc@hotmail.com> wrote:> > i have three data, x coordinate, y coordinate and signal strength > > i use tapply() function to get the average ss in the give x,y location > x=c(1,2,3,1) > y=c(1,2,3,1) > ss=c(55,NA,55,88) > ss_byxy_test=tapply( ss, list( x, y), mean) > and I get this table > 1 2 3 > 1 71.5 NA NA > 2 NA NA NA > 3 NA NA 55 > but i don't know how to plot different the ss with the xy location, > can anyone help me > -- > View this message in context: > http://n4.nabble.com/plot-data-from-tapply-tp949436p949436.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<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]]
I left off the statement to load the reshape package. If you don't have it, install it from CRAN: x=c(1,2,3,1) y=c(1,2,3,1) ss=c(55,NA,55,88) ss_byxy_test=tapply( ss, list( x, y), mean, na.rm=TRUE) ss_byxy_test # use the 'reshape' package library(reshape) # now 'melt' the data to get it into a format for plotting (ss_melt <- melt(ss_byxy_test)) # create the plot area so you can add the 'ss' as text plot(0, type='n', xlim=range(ss_melt$X1), ylim=range(ss_melt$X2), xlab="X", ylab="Y") text(ss_melt$X1, ss_melt$X2, ss_melt$value, font=2, col='red') On Sat, Dec 5, 2009 at 4:49 PM, dwwc <dwwc@hotmail.com> wrote:> > i have three data, x coordinate, y coordinate and signal strength > > i use tapply() function to get the average ss in the give x,y location > x=c(1,2,3,1) > y=c(1,2,3,1) > ss=c(55,NA,55,88) > ss_byxy_test=tapply( ss, list( x, y), mean) > and I get this table > 1 2 3 > 1 71.5 NA NA > 2 NA NA NA > 3 NA NA 55 > but i don't know how to plot different the ss with the xy location, > can anyone help me > -- > View this message in context: > http://n4.nabble.com/plot-data-from-tapply-tp949436p949436.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<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]]