Question: Can you please help me with this using R please : provide a custom function called irisColor(). Your function should take in a single character
Can you please help me with this using R please :
- provide a custom function called irisColor().
- Your function should take in a single character string as the only input.
- If the input is "setosa", return "red"
- If the input is "versicolor", return "lightblue"
- If the input is "virginica", return "purple"
- If the input is not one of the above, throw an informative error
- Use sapply() and your custom function to produce an array of length 150 that has these three colors by species for the 150 specimens in the iris data set.
- Plot petal width (Y) against petal length (X), using a scatterplot. Make your plot useful by giving it appropriate labels. The main title of the plot should be your name. Additionally, use a solid plotting mark (like pch=20) and color them by species via giving col= your array from b).
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
