0
表卸下行我用下面的代碼來刮表成R.從R中
player.offense.201702050atl = comments.201702050atl[31] %>% html_text() %>% read_html() %>% html_node("#player_offense") %>% html_table()
然後改變使用的列標籤:
colnames(player.offense.201702050atl) = c("Player", "Tm", "Cmp.Passing", "Att.Passing", "Yds.Passing", "TD.Passing", "Int.Passing", "Sk.Passing", "Yds.Sk.Passing", "Lng.Passing", "Rate.Passing", "Att.Rushing", "Yds.Rushing", "TD.Rushing", "Lng.Rushing", "Tgt.Receiving", "Rec.Receiving", "Yds.Receiving", "TD.Receiving", "Lng.Receiving", "Fmb.Fumbles", "FL.Fumbles")
接下來,我需要消除的行1 ,11和12
我可以使用:
player.offense.201702050atl.a = player.offense.201702050atl[2:10, ]
player.offense.201702050atl.b = player.offense.201702050atl[13:20, ]
player.offense.201702050atl.c = rbind(player.offense.201702050atl.a, player.offense.201702050atl.b)
但是,我有多個表需要類似的操作;而且,我打算消除的行因每個而不同。我希望消除的行的標準是:
列3中值爲「Cmp」或「Passing」的所有行。
有沒有辦法運行一個函數來分析表,標識滿足上述條件的行並將其消除?
你可以刪除線,負。 'df [-c(1,11,12)]'' –