_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › dplyr

Contents

1 inner join
2 豌 5襷
3 蠍磯蓋
4 谿瑚襭


1 inner join #

> data1
  id mid
1 23  43
2  4  56
3 78  29
4 54  99
> data2
  id final
1  4    77
2 23     2
3 54    19
4 70    31
> dplyr::inner_join(data1, data2, by="id")
  id mid final
1 23  43     2
2  4  56    77
3 54  99    19

2 豌 5襷 #

dplyr::filter(df, row_number() <= 5)

3 蠍磯蓋 #

#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))


蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:53

伎 襷 螳語. 螳伎 願 覲企 企 螳 蟇磯Μ螳 螳讌蟾. 螳 蟇磯Μ螳 螳 谿語 蟆 讀螳 螳伎 . 螳 蠏手碓襴螻 手 誤 磯Μ 覲旧 螻煙朱 蟷伎. (豈覺)