I have a simple table, 2 columns and 1994 rows. First row, "Crime" is how
many crimes happen every month per 100000 inhabitants and second row is
"Income" which contains the average income recorded in a city.

here's the head(dataset):

    Crime      Income
1 356.5152 4285.720
2 734.5625 4114.291
3 541.5171 3542.861
4 292.1667 4057.148
5 219.7747 4457.149
6 308.2538 6114.296

I want to stratify the crime based on income and then box plot each stratum
to compare. Also I need to get the variance of each stratum in a table.

this is the summary of the Income column:

Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
2000    3257    3714    4001    4457    7714


Closer I've been able to get is this:
strata=table(cut(dataset$Income, breaks, right= FALSE))

where breaks is
> breaks
 [1] 2000 3500 5000 6500 8000

this gives me as result:
> cbind(strata)
                          strata
[2e+03,3.5e+03)      805
[3.5e+03,5e+03)      894
[5e+03,6.5e+03)      206
[6.5e+03,8e+03)       89


I'm not even sure if that's the right way to get the strata.

*The important thing here is I need to find a way to get a boxplot of the
Crime values in each stratum and the variance too.
*
Thanks so much in advance.

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to