问题描述
我在下面有这样的代码:
act[,-c(1,2)]%>%
mutate(Cluster = km$cluster) %>%
group_by(Cluster) %>%
summarise_all("mean")
这是结果。
# A tibble: 3 x 12
Cluster sleep_PersonalActivity PaidWorking Studying Transport UnpaidWorking Socializing
<int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 1 10.0 3.84 0 1.19 3.23 0.931
2 2 11.1 2.07 1.62 1.12 1.43 0.918
3 3 11.1 0.639 0 0.917 3.43 1.00
# ... with 5 more variables: CivicReligIoUs <dbl>,Sport <dbl>,ActiveLeisure <dbl>,# PassiveLeisure <dbl>,Others <dbl>
数据框有 9 个变量:
sleep_PersonalActivity、有偿工作、学习、交通、无偿工作、社交、公民宗教、运动、主动休闲、被动休闲、其他。
如何让 R 在结果中显示所有变量?我需要调整标题大小吗?如果是这样,我该怎么办?感谢所有帮助。
解决方法
这是因为 print
的 tibble
设置。我们可以指定 width
到 Inf
print(out,width = Inf)
哪里
out <- act[,-c(1,2)]%>%
mutate(Cluster = km$cluster) %>%
group_by(Cluster) %>%
summarise_all("mean")
View(out)
输出或我们使用 data.frame
转换为 as.data.frame
不会有任何问题