Skip to content

draw points in R

3 messages · Sarah Goslee, Adel ESSAFI

#
Hi,
That seems unlikely, but without your code it's hard to figure out
what you did. As usual, the telepathy is not working.

Regardless, this will create a graph with points:

x <- read.table("clipboard", header=FALSE, as.is=TRUE)
# including data is good; including data with dput() is better

plot(x[,2], x[,3], type="p", xlab="X", ylab="Y", main="Points")
And here's one way to color them:
plot(x[,2], x[,3], col=c("red", "blue", "green")[as.factor(x[,1])],
xlab="X", ylab="Y", main="Colored Points")

You might be interested in ?par especially pch and also in ?legend
as well as in the basic help for ?plot and ?points.

Sarah
On Wed, Sep 14, 2011 at 1:57 PM, Adel ESSAFI <adelessafi at gmail.com> wrote: