0
votes

In R, the iris table contains the following attributes:

  • Sepal.Length
  • Sepal.Width
  • Petal.Length
  • Petal.Width
  • Species

I have learned that it's possible to use the following package to view a scatter plot of 2 values only in the dataset which are Sepal.Length & Sepal.Width in this case:

library(ggvis)
iris %>% ggvis(~Sepal.Length, ~Sepal.Width, fill = ~Species) %>%
layer_points()

My question is as follows: I need to have the scatter plot but for the the first 4 attributes in the dataset to represent the species. How can this be done?

If not in R, is there any other tool that can do this?

1
Make a scatterplot matrix, googling for r scatterplot matrix or r ggplot2 scatterplot matrix should get you started. - Paul Hiemstra
Thank you.. will check it for sure :) - HE Prog

1 Answers

2
votes

You can use the built-in functin pairs. If you want to add colors to it as in your example, you can add parameter col. Here you have the code:

pairs(iris[,1:4], col = iris$Species, pch=16) # parameter pch=16 changes the points to be filled dots.

Output:

enter image description here