简体   繁体   中英

Statistics with R Software - Data and intervals

I have the following data :

women_height <- c(105,110,112,112,118,119,120,120,125,126,
                  127,128,130,132,133,134,135,138,138,138,
                  138,142,145,148,148,150,151,154,154,158)

and the following intervals :

]104;114];]114;124];]124;134];]134;144];]144;154];]154;164];]164;174];]174;184]

How can I found how much women have an height between each interval ? For exemple :

]104;114] --> 4 matches

]114;124] ---> 4 matches

...

You can do a combination of cut (with use of seq for the breaks) and table :

table(cut(women_height, breaks=seq(104, 184, by=10)))

#(104,114] (114,124] (124,134] (134,144] (144,154] (154,164] (164,174] (174,184] 
#        4         4         8         6         7         1         0         0 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM