How to make a iris data as ggplot graph? help me to make that

Since this is for an assignment I can't give you a complete solution to produce the plot (check our homework policy), but I can help you with the gathering step, instead of specifying the values of the Species column (i.e. c("setosa","versicolor","virginica")), you have to tell gather() function, to exclude the Species column from the gathering, like this:

library(tidyverse)

iris %>%
    gather(key = feature, value = value, -Species)
#> # A tibble: 600 x 3
#>    Species feature      value
#>    <fct>   <chr>        <dbl>
#>  1 setosa  Sepal.Length   5.1
#>  2 setosa  Sepal.Length   4.9
#>  3 setosa  Sepal.Length   4.7
#>  4 setosa  Sepal.Length   4.6
#>  5 setosa  Sepal.Length   5  
#>  6 setosa  Sepal.Length   5.4
#>  7 setosa  Sepal.Length   4.6
#>  8 setosa  Sepal.Length   5  
#>  9 setosa  Sepal.Length   4.4
#> 10 setosa  Sepal.Length   4.9
#> # … with 590 more rows

Created on 2019-12-01 by the reprex package (v0.3.0.9000)

As an extra hint, you can use ggplot2::geom_jitter() to produce that kind of plot.

2 Likes