Guest User

Untitled

a guest
Sep 10th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.35 KB | None | 0 0
  1.  
  2. normalize <- function(x) {
  3.   r = range(x)
  4.   m = r[2] - r[1]
  5.   (x - r[1]) / m
  6. }
  7.  
  8. colors = rainbow(8)
  9.  
  10. p1 = xyplot(Sepal.Length~Sepal.Width|Species,iris,col=colors[round(normalize(iris$Petal.Length)*7)+1])
  11.  
  12. p2 = xyplot(Sepal.Length~Sepal.Width,iris,col=colors[round(normalize(iris$Petal.Length)*7)+1],pch=as.numeric(iris$Species))
  13.  
  14. print(c(p1, p2))
Add Comment
Please, Sign In to add comment