[R] Scatter plot selection points

Beatriz aguitatierra at hotmail.com
Fri May 30 09:37:14 CEST 2014


Hi all,

I'd like to do a scatterplot where some of the values, out of a subset, 
are plotted differently in color and shape.
I've worked around the following code but I don't manage to make it right.
Any help greatly appreciated!

# My data
dd <- iris
iris$Code <- 1:150

# A selection of my data I'd like to plot differently
subset <- subset(iris, iris$Sepal.Width<5)
sel <- as.character(subset$Code) # I think the problems start already 
here :)

# Plotting doesn't work
plot(iris$Sepal.Length ~ iris$Sepal.Widith,
      col=ifelse(iris$Code==sel, "red", "black")
      pch=ifelse(iris$Code==sel, 17, 1))



More information about the R-help mailing list