#install.packages("dplyr")
library("dplyr")
df <- tbl_df(iris)
df
class(df)
#
filter(df, Species == "setosa", Sepal.Length >= 4)
filter(df, Species == "setosa" | Species == "versicolor")
#
arrange(df, Sepal.Length, desc(Sepal.Width))
#轟 貉朱 譟壱
select(df, Sepal.Length, Species)
select(df, -Species)
select(df, Sepal.Width:Petal.Width)
select(df, -(Sepal.Width:Petal.Width))
#伎螳
mutate(df, compute = Sepal.Length * Sepal.Width, total.Sepal.Length = sum(Sepal.Length))
transform(df, compute = Sepal.Length * Sepal.Width, total.Sepal.Length = sum(Sepal.Length))
#讌螻
summarise(df, total=sum(Sepal.Length))
summarise(group_by(df, Species), total=sum(Sepal.Length))
#chain 蠍磯
group_by(df, Species) %>% filter(Sepal.Length >= 5) %>% summarise(total=sum(Sepal.Length))