Final-Exam_Q4_Ning-Wan.docx - Final-Exam_Q4_Ning-Wan.R...

This preview shows page 1 - 3 out of 3 pages.

Final-Exam_Q4_Ning-Wan.R wanning 2020-08-09 #Ning Wan #Final Exam -- Question 4 load ( "all.RData" ) ss <- all_col str (ss) ## 'data.frame': 299 obs. of 6 variables: ## $ id : chr "S001" "S002" "S003" "S004" ... ## $ Species : chr "setosa" "setosa" "setosa" "setosa" ... ## $ Sepal.Length: num 4.75 5.07 5.24 5.48 4.9 ... ## $ Sepal.Width : num 3.3 3.68 3.44 3.96 2.81 ... ## $ Petal.Length: num 1.44 1.21 1.59 1.53 1.49 ... ## $ Petal.Width : num 0.235 0.111 0.405 0.272 0.345 ... ss $ Species = as.factor (ss $ Species) h0 <- subset (ss,Species == "setosa" | Species == "versicolor" ) summary (h0) ## id Species Sepal.Length Sepal.Width ## Length:199 setosa : 99 Min. :4.417 Min. : 1.912 ## Class :character versicolor:100 1st Qu.:5.068 1st Qu.:2.712 ## Mode :character virginica : 0 Median :5.443 Median : 3.063 ## Mean :5.542 Mean : 3.129 ## 3rd Qu.:6.011 3rd Qu.:3.543 ## Max. :7.124 Max. : 4.810 ## Petal.Length Petal.Width ## Min. :1.135 Min. :0.01781 ## 1st Qu.:1.487 1st Qu.:0.24180 ## Median :2.945 Median :0.90882 ## Mean :2.857 Mean :0.77060 ## 3rd Qu.:4.228 3rd Qu.:1.28776 ## Max. :5.577 Max. :1.86826 #I extracted data only for Setosa and Versicolor.
plot (h0 $ Sepal.Length, data = h0, pch = 16 , col = c ( "red" , "steelblue" )[h0 $ Species]) ## Warning in plot.window(...): "data" is not a graphical parameter ## Warning in plot.xy(xy, type, ...): "data" is not a graphical

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture