Final-Exam_Q2_Ning-Wan.docx - Final-Exam_Q2_Ning-Wan.R...

This preview shows page 1 - 8 out of 9 pages.

Final-Exam_Q2_Ning-Wan.R wanning 2020-08-09 #Ning Wan #Final Exam -- Question 2 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) ss $ Species <- as.numeric (ss $ Species) plot (Petal.Length ~ Sepal.Length, data = ss, pch = 16 , col = c ( "red" , "steelblue" , "green3" )[ss $ Species])
plot (Petal.Width ~ Sepal.Width, data = ss, pch = 16 , col = c ( "red" , "steelblue" , "green3" )[ss $ Species])
plot (Sepal.Length ~ Sepal.Width, data = ss, pch = 16 , col = c ( "red" , "steelblue" , "green3" )[ss $ Species])
plot (Sepal.Length ~ Petal.Width, data = ss, pch = 16 , col = c ( "red" , "steelblue" , "green3" )[ss $ Species])
plot (Petal.Length ~ Sepal.Width, data = ss, pch = 16 , col = c ( "red" , "steelblue" , "green3" )[ss $ Species])
plot (Petal.Length ~ Petal.Width, data = ss, pch = 16 , col = c ( "red" , "steelblue" , "green3" )[ss $ Species])
#The combination of Petal Length and Petal Width can distinguish each species most clearly.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture