我有一個關於1960年至2014年間在不同國家進行的調查的統一數據集。我想放棄同一年在同一個國家進行過兩次不同調查的行。我不確定如何在dplyr中使用過濾器動詞從協調數據集中刪除行。使用dplyr過濾數據框中的行
Harm_data1 %>%
group_by(country, survey, year, protest demo , protest fact) %>%
filter(country >= 2 | year >=2)
我有一個關於1960年至2014年間在不同國家進行的調查的統一數據集。我想放棄同一年在同一個國家進行過兩次不同調查的行。我不確定如何在dplyr中使用過濾器動詞從協調數據集中刪除行。使用dplyr過濾數據框中的行
Harm_data1 %>%
group_by(country, survey, year, protest demo , protest fact) %>%
filter(country >= 2 | year >=2)
你是說你想要輸出到一個新表?我相信你上面的話會給出與你所要求的完全相反的東西,它只會返回那些更大的東西。我會做:
Harm_data1 %>%
group_by(country, survey, year, protest demo , protest fact) %>%
filter(country < 2 | year < 2)
'Harm_data1%>%GROUP_BY(國家,年)%>%的過濾器(N()== 1)' – alistaire