그룹화하려는 열이 많은 빅 데이터 프레임을 다루고 있습니다. 다음과 같이하고 싶습니다.
output <- df %>%
group_by(starts_with("GEN", ignore.case=TRUE),x,y) %>%
summarize(total=n()) %>%
arrange(desc(total))
이것을 할 방법이 있습니까? group_by_at 또는 다른 유사한 기능을 사용할 수 있습니까?
사용하기 starts_with()
에 group_by()
, 당신은 그것을 포장해야합니다 across()
. 다음은 일부 빌드 된 데이터를 사용하는 예입니다.
library(dplyr)
mtcars %>%
group_by(across(starts_with("c"))) %>%
summarize(total = n()) %>%
arrange(-total)
# A tibble: 9 x 3
# Groups: cyl [3]
cyl carb total
<dbl> <dbl> <int>
1 4 2 6
2 8 4 6
3 4 1 5
4 6 4 4
5 8 2 4
6 8 3 3
7 6 1 2
8 6 6 1
9 8 8 1
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다