Question

The famous data set iris which gives the measurements in centimeters of the variables sepal length...

The famous data set iris which 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 is available in R. Type iris directly to see what it looks like.

(a) Selecting the observations (rows) whose Species are versicolor.

(b) Selecting the observations whose Speices are either versicolor or virginica.

(c) Selecting the observations whose Sepal.Width are greater than 2.9 but less than 3.5.

(d) Combine the data frames you got in part (a) and part (c) to one data frame.

(e) You may have some duplicated observations in the data frame you obtained in part (d). Use the command ?unique to learn the usage of the function unique and then utilize it to remove duplicated rows from the data frame you obtained in part (d).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

R CODE:

iris

# Q1.

iris_a = iris[iris$Species == "versicolor", ]
iris_a

# Q2.

iris_b = iris[iris$Species == "versicolor" | iris$Species == "virginica" , ]
iris_b

# Q3.

iris_c = iris[iris$Sepal.Width > 2.9 & iris$Sepal.Width < 3.5 , ]
iris_c

# Q4.

iris_d = rbind(iris_a, iris_c)
iris_d

# Q5.

iris_e = unique(iris_d)
iris_e

# Result related
> nrow(iris_d)
[1] 118
> nrow(iris_e)
[1] 102

Add a comment
Know the answer?
Add Answer to:
The famous data set iris which gives the measurements in centimeters of the variables sepal length...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT