[R] plot the number of replicates at the same point

Deepayan Sarkar deepayan.sarkar at gmail.com
Thu Jul 14 19:30:54 CEST 2005


On 7/14/05, Kerry Bush <kerryrekky at yahoo.com> wrote:
> Thank you for thinking about the problem for me.
> However, I have found that your method doesn't work at
> all.
> 
> You may test the following example:
> 
> x1=c(0.6,0.4,.4,.4,.2,.2,.2,0,0)
> x2=c(0.4,.2,.4,.6,0,.2,.4,0,.2)
> x1=rep(x1,4)
> x2=rep(x2,4)
> temp=data.frame(x1,x2)
> temp1=table(temp)
> plot(temp$x1,temp$x2,cex=0)
> text(as.numeric(rownames(temp1)),
> as.numeric(colnames(temp1)), temp1)
> 
> what I got here is not what I wanted. You may compare
> with
> plot(x1,x2)
> 
> I actually want some plots similar to what SAS proc
> plot produced.
> 
> Does anybody have a clue of how to do this easily in
> R?

Try this:


x1=c(0.6,0.4,.4,.4,.2,.2,.2,0,0)
x2=c(0.4,.2,.4,.6,0,.2,.4,0,.2)
x1=rep(x1,4)
x2=rep(x2,4)
temp=data.frame(x1,x2)

foo <- subset(as.data.frame(table(temp)), Freq > 0)
foo$x1 <- as.numeric(as.character(foo$x1))
foo$x2 <- as.numeric(as.character(foo$x2))

with(foo, plot(x1, x2, type = "n"))
with(foo, text(x1, x2, lab = Freq))


-Deepayan




More information about the R-help mailing list