iris$Sepal.Length
<aside> 💡 [1] "more then 5" "less than 5" "less than 5" "less than 5" "less than 5" "more then 5" "less than 5" [8] "less than 5" "less than 5" "less than 5" "more then 5" "less than 5" "less than 5" "less than 5" [15] "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" [22] "more then 5" "less than 5" "more then 5" "less than 5" "less than 5" "less than 5" "more then 5" [29] "more then 5" "less than 5" "less than 5" "more then 5" "more then 5" "more then 5" "less than 5" [36] "less than 5" "more then 5" "less than 5" "less than 5" "more then 5" "less than 5" "less than 5" [43] "less than 5" "less than 5" "more then 5" "less than 5" "more then 5" "less than 5" "more then 5" [50] "less than 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" [57] "more then 5" "less than 5" "more then 5" "more then 5" "less than 5" "more then 5" "more then 5" [64] "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" [71] "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" [78] "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" [85] "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" [92] "more then 5" "more then 5" "less than 5" "more then 5" "more then 5" "more then 5" "more then 5" [99] "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" [106] "more then 5" "less than 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" [113] "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" [120] "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" [127] "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" [134] "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" [141] "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" "more then 5" [148] "more then 5" "more then 5" "more then 5”
</aside>
y<-ifelse(
iris$Sepal.Length>5, "more then 5", "less than 5"
)
y
#변수 생성 후 y 값 입력
iris$Sepal.Length_level<-y
head(iris)
head(iris) Sepal.Length Sepal.Width Petal.Length Petal.Width Species Sepal.Length_level 1 5.1 3.5 1.4 0.2 setosa more then 5 2 4.9 3.0 1.4 0.2 setosa less than 5 3 4.7 3.2 1.3 0.2 setosa less than 5 4 4.6 3.1 1.5 0.2 setosa less than 5 5 5.0 3.6 1.4 0.2 setosa less than 5 6 5.4 3.9 1.7 0.4 setosa more then 5
Species Sepal.Length 1 setosa 5.006 2 versicolor 5.936 3 virginica 6.588
aggregate(Sepal.Length ~ Species, data=iris,mean)
aggregate(Sepal.Length ~ Species, data=iris,sum)
Species Sepal.Length 1 setosa 250.3 2 versicolor 296.8 3 virginica 329.4
aggregate(. ~ Species, data=iris,mean)
Species | Sepal.Length | Sepal.Width | Petal.Length | Petal.Width |
---|---|---|---|---|
1 | 5.006 | 3.428 | 1.462 | 0.246 |
2 | 5.936 | 2.770 | 4.260 | 1.326 |
3 | 6.588 | 2.974 | 5.552 | 2.026 |