1.计算占比(prop.table)
trip %>%
count(usertype) %>%
select(n) %>%
prop.table() %>%
lapply(percent)
2.将小数用百分数表示(percent)
percent(0.93)
输出:93%
3.计算分位数
quantile(trip$tripduration/60, probs = c(0, 0.25, 0.5, 0.75, 1))
输出:
0% 25% 50% 75% 100%
1.00000 6.35000 10.93333 18.56667 436.43333
4.排序
trip %>%
filter(usertype == "Subscriber" & gender == "Female") %>%
group_by(to_station_name) %>%
summarise(n = n()) %>%
arrange(desc(n)) %>%
head(3) %>%
select(n)
arrange(desc())即可用来排序