Conditional statement assignment
Title
Question
assignment question:
Use the built-in data set iris. Find the Species, in which Sepal.Length is greater than Petal.Length.
2. Count all such Species.
solution:
iris$find = ifelse(iris$Sepal.Length > iris$Petal.Length,1,0)
View(iris)
sum(ifelse(iris$Sepal.Length > iris$Petal.Length,1,0))
[1] 150
Is it correct or any better code can be implemented ?
R Conditional-Statements 10-11 min 40-50 sec
Answers:
It is one of the possible ways.
Login to add comment