R 如何查看非表格形式的输出的所有行
问题 我从一个未分组的数据集开始,然后对其进行分组,但是分组的输出不会返回所有427行。需要输出将该数据输入到表中 因此,最初数据被取消分组,如下所示:R 如何查看非表格形式的输出的所有行,r,R,问题 我从一个未分组的数据集开始,然后对其进行分组,但是分组的输出不会返回所有427行。需要输出将该数据输入到表中 因此,最初数据被取消分组,如下所示: Occupation Education Age Died 1 household Secondary 39 no 2 farming primary 83 yes 3 farming primary 60 yes 4 farming primary 73 yes 5 farming Se
Occupation Education Age Died
1 household Secondary 39 no
2 farming primary 83 yes
3 farming primary 60 yes
4 farming primary 73 yes
5 farming Secondary 51 no
6 farming iliterate 62 yes
occu %>% group_by(Occupation, Died, Age) %>% count()##use this to group on the occupation of the suicide victimrs
然后将数据分组如下:
Occupation Education Age Died
1 household Secondary 39 no
2 farming primary 83 yes
3 farming primary 60 yes
4 farming primary 73 yes
5 farming Secondary 51 no
6 farming iliterate 62 yes
occu %>% group_by(Occupation, Died, Age) %>% count()##use this to group on the occupation of the suicide victimrs
这将提供以下输出:
Occupation Died Age n
<fct> <fct> <int> <int>
1 business/service no 20 2
2 business/service no 30 1
3 business/service no 31 2
4 business/service no 34 1
5 business/service no 36 2
6 business/service no 41 1
7 business/service no 44 1
8 business/service no 46 1
9 business/service no 84 1
10 business/service yes 21 1
# ... with 417 more rows
职业死亡年龄n
1商业/服务编号20 2
2商业/服务编号30 1
3业务/服务编号31 2
4业务/服务编号34 1
5商业/服务编号36 2
6业务/服务编号41 1
7业务/服务编号44 1
8业务/服务编号46 1
9业务/服务编号84 1
10业务/服务是21 1
# ... 还有417行
问题是我需要所有行,以便使用以下命令将分组数据输入到表中:
dt <- read.table(text="full output from above")
dt不太清楚您想要什么,但请尝试以下代码:
occu %>% group_by(Occupation, Died, Age) %>% count()
dt <- as.data.frame(occu)
它将允许R将完整的TIBLE
打印到控制台中,我认为这对执行您的要求是无效的。我不确定我是否得到了您想要的,您可以添加您想要的输出吗?您不能将as.table()
应用到您的occum代码>行?无需打印到控制台并再次阅读,希望r更智能;)所以我想要与上面给出的完全相同的输出,但是如果可能的话,所有417行都是打印选项输出。它可以在TIBLE打印选项中更改。检查您是否可以不简单地将作为.data.frame执行?否则,如果您真的想打印控制台中的所有表,请遵循Akrun的链接。