Write an R script to create a scatter plot, incorporating categorical analysis through color-coded data points representing different groups, using ggplot2.
Step 1: Load the necessary libraries
library(ggplot2)library(dplyr)
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
library(tidyr)
Step 2: Load the dataset
Explanation:
The iris dataset contains 150 samples of iris flowers categorized into three species: setosa, versicolor, and virginica.
Each sample has sepal and petal measurements.
head(data) displays the first few rows
#load the iris datasetdata <- iris# Display first few rowshead(data)