#attach() detach() search()
Sepal.Width
attach(iris)
search()
head(Sepal.Length)
detach(iris)
search()
Sepal.Width
#if you changed values in sepal with after use attach(), the changed values do not affect iris
##index
#which() which.max() , which.min()
subset(iris,Species =="setosa")
which(iris$Species =="setosa")
which.max(iris$Sepal.Length)
which.min(iris$Sepal.Length)
##calculation by group
#aggregate(x,by,function) or aggregate(formula(y~x),data, function)
aggregate(Sepal.Length ~ Species, iris, mean)
tapply(iris$Sepal.Length, iris$Species, mean)
library(doBy)
summaryBy(Sepal.Length~ iris$Species, iris)
##Tidy Data
#stack() unstack()
x<-data.frame(a=c(3,2,9),b=c(5,3,2),c=c(4,5,7))
x
(xstacked <- stack(x))
summaryBy(values~ind, xstacked)
unstack(xstacked,values~ind)
'R' 카테고리의 다른 글
R - sort(), with(), within(), merge(),order() - 2020/01/14 (0) | 2020.01.14 |
---|---|
R - Basic R stat on iris - 2020/01/08 (0) | 2020.01.08 |
R - function(), queue, Module Pattern - 2020/01/08 (0) | 2020.01.08 |
R - datatype, iteration,vector computation, NA - 2020/01/08 (0) | 2020.01.08 |
R - array(), data.frame() - 2020/01/07 (0) | 2020.01.07 |