[R] Calculate the median age interval
Erik B Svensson
erik.b.svensson at gmail.com
Mon Jan 12 11:32:41 CET 2015
Hello
I've got a problem I don't know how to solve. I have got a dataset that
contains age intervals (age groups) of people and the number of persons in
each age group each year (y1994-y1996). The number of persons varies each
year. I only have access to the age intervals, not the age of each person,
which would make things easier.
I want to know the median age interval (not the median number) for each
year. Let's say that in y1994 23 corresponds to the median age interval
"45-54", I want to "45-54" as a result. How is that done?
This is the sample dataset:
agegrp <-
c("<1","1-4","5-14","15-24","25-34","35-44","45-54","55-64","65-74","75-84","84-")
y1994 <- c(0,5,7,9,25,44,23,32,40,36,8)
y1995 <- c(2,4,1,7,20,39,32,18,21,23,5)
y1996 <- c(1,3,1,4,22,37,41,24,24,26,8)
I look forward to your response
Best regards,
Erik Svensson
[[alternative HTML version deleted]]
More information about the R-help
mailing list