Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在R中,如何将数据分配到不同的组中_R - Fatal编程技术网

在R中,如何将数据分配到不同的组中

在R中,如何将数据分配到不同的组中,r,R,我有一组像1-10,10-20,20-30,30-40。我有像“1,23,24,11,33,22,5,6,7,8,3,2”这样的数据 如何确定每组中有多少人?您还可以使用hist功能: R> table(cut(c(1,23,24,11,33,22,5,6,7,8,3,2), breaks=seq(0, 40, by=10), right=FALSE)) [0,10) [10,20) [20,30) [30,40) 7 1

我有一组像1-10,10-20,20-30,30-40。我有像“1,23,24,11,33,22,5,6,7,8,3,2”这样的数据
如何确定每组中有多少人?您还可以使用hist功能:

R> table(cut(c(1,23,24,11,33,22,5,6,7,8,3,2), 
             breaks=seq(0, 40, by=10), right=FALSE))

 [0,10) [10,20) [20,30) [30,40) 
      7       1       3       1 
y <- c(1,23,24,11,33,22,5,6,7,8,3,2)
h <- hist(y, seq(0, 40, 10), plot=0) # plot=0 avoids plotting the histogram
# Refer to h$counts to get the counts in each bin

y您可以使用which函数执行所需操作(例如,长度(which(data>=1&data<10)))。如果你更详细地描述你的团队是如何被代表的,你可能会得到更详细的答案。