Background: Edgar Andersons Iris Data
The R data description follows:
This famous (Fishers or Andersons) iris data set gives the measurements in centimeters of the variables sepal length and width and petal length and width, respectively, for 50 flowers from each of 3 species of iris. The species are Iris setosa, versicolor, and virginica.
Tasks
The purpose of this lab is to construct two complex plots using base R graphics.
- Construct the exact plot png that is posted on Canvas. Move the legend to the topleft, change the xlab & ylab to Sepal Length & Petal Length respectively, and change the title to something else.
## R code goes here
- Plot four normal distributions using different colors and placing line segments at the mean of each distribution. Include a legend, update the title and change the vertical & horizontal limits so that the plot looks nice. Use the function dnorm() to plot the normal density. The normal distributions are:
N( = 0,2 = 1), N( = 2,2 = 9/16), N( = 2,2 = 4), N( = 4,2 = 1/4),
Note that the function dnorm() uses standard deviation () and do not use variance (2). The code below should get you started.
# Define x and y points x <- seq(10,10,by=.01) normal_1 <- dnorm(x,mean=0,sd=1)# Construct base plot# Plot x and y points and connect the dots plot(x,normal_1, xlim=c(5,5),ylim=c(.2,.6), type=l,col=blue, ylab=Densities, main=Normal Distributions) |
1
# Use lines() to add other plots# Line segements segments(x0=0,y0=0,x1=0,y1=dnorm(0,mean=0,sd=1),lty=3)# Legend legend(topleft,legend=c(N(0,1)),col=c(blue), lty=c(1,1,1,1),cex=1)# Horizontal axis abline(h=0,lty=2) |
Normal Distributions
x
Reviews
There are no reviews yet.