2020. 1. 8. 00:07 IT/R (데이터전처리대전 따라하기)
R 데이터 요약하기
그룹별 Summary 데이터 구하기1
#호텔id 별 Summary 데이터구하기1
reserve_table %>%
#hotel_id로 group by
group_by(hotel_id) %>%
#예약건수(단순count), 고객수(count(distinct customer_id)) ..
summarise(rsv_cnt=n()
,cus_cnt=n_distinct(customer_id)
,price_sum=sum(total_price)
,max_price=max(total_price)
,min_price=min(total_price)
,mean_price=mean(total_price)
,median_price=median(total_price)
,quantile_price=quantile(total_price,0.25)
)
#데이터프레임의 요약 데이터 구하기
reserve_table %>%
#summary 함수를 통해 그룹별 평균, 분산,4분위 등.. 대표값을 자동으로 출력함
summary()

'IT > R (데이터전처리대전 따라하기)' 카테고리의 다른 글
R 최빈값 구하기 (1) | 2020.01.08 |
---|---|
R 분산, 표준편차 구하기 (0) | 2020.01.08 |
R 데이터샘플링 (0) | 2020.01.07 |
R 조건(where절)에 따른 데이터 추출 (0) | 2020.01.07 |
R 데이터 행,열 지정 추출 (0) | 2020.01.06 |