[R] summary and plot
Richard M. Heiberger
rmh at temple.edu
Fri Oct 11 05:19:41 CEST 2013
This is better for plotting the percents
likert(city ~ F + M | year, data=popwide, as.percent="noRightAxis",
main="F M population by city within year")
likert(year ~ F + M | city, data=popwide, as.percent="noRightAxis",
main="F M population by year within city")
We can also plot the populations
likert(city ~ F + M | year, data=popwide,
main="F M population by city within year")
likert(year ~ F + M | city, data=popwide,
main="F M population by year within city")
The row count totals in the percent plots in my previous email belong
only to the first panel.
This is a bug that I will need to fix.
Rich
On Thu, Oct 10, 2013 at 11:04 PM, Richard M. Heiberger <rmh at temple.edu> wrote:
> ## I would use the likert function in the HH package
>
> ## if necessary
> ## install.packages("HH")
> ## install.packages("reshape")
>
> library(HH)
>
> library(reshape)
>
>
> pop <- read.table(header=TRUE, text="
> city year sex obs
> 1 1990 M 25
> 1 1990 F 32
> 1 1991 M 15
> 1 1991 F 22
> 2 1990 M 42
> 2 1990 F 36
> 2 1991 M 12
> 2 1991 F 16
> ")
>
> popwide <- cast(val, city + year ~ sex, value="obs")
> popwide
>
> likert(city ~ F + M | year, data=popwide, as.percent=TRUE,
> main="F M population by city within year")
>
> likert(year ~ F + M | city, data=popwide, as.percent=TRUE,
> main="F M population by year within city")
>
> ## Rich
>
> On Thu, Oct 10, 2013 at 10:35 PM, Val <valkremk at gmail.com> wrote:
>> Hi All,
>>
>> I have a huge data set with the following type;
>> city year sex obs
>> 1 1990 M 25
>> 1 1990 F 32
>> 1 1991 M 15
>> 1 1991 F 22
>> 2 1990 M 42
>> 2 1990 F 36
>> 2 1991 M 12
>> 2 1991 F 16
>>
>> I want to calculate the percentage of M and F by city, year and year
>> within city and also plot.
>> city 1 total Male= 40; total female= 54;
>> %M= 40/(40+54)=42.6
>> %F= 54/(40+54)=57.4
>>
>> and so on.
>>
>> Can any body help me out?
>>
>> Thanks in advance
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at 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.
More information about the R-help
mailing list