please look at the likert function in the HH package. It is designed for this
type of study.
?likert has many examples similar to yours.
Rich
Sent from my iPhone
On Jun 7, 2012, at 8:42, Patrick Hubers <stompertje at gmail.com> wrote:
> Hi,
>
> I'm trying to create a stacked bar plot with the satisfaction scores
from a
> customer satisfaction survey. I have results for three stores over several
> weeks and want to create a weekly graph with a stacked bar for each store.
> I can flatten the dataframe into a table with absolute frequencies, but I
> can't find how to get relative frequencies. My dataset looks similar to
the
> example below:
>
> Satisfaction <- c(1,1,2,3,4,5,2,2,2,3,1,1,4,5,4,2,3,2,2,2,3,1,3,2,4)
> Store <- c(1,1,2,3,3,2,2,1,2,3,1,2,3,2,1,3,2,1,2,1,2,3,2,1,3)
> Week <- c(1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4)
> csat <- data.frame(Satisfaction, Store, Week)
> csat[,1] <- factor(csat[,1], levels=c(1,2,3,4,5), labels=c("Very
> satisfied", "Satisfied", "Neutral",
"Dissatisfied", "Very dissatisfied"))
> csat[,2] <- factor(csat[,2], levels=c(1,2,3), labels=c("New
York", "Paris",
> "Johannesburg"))
> csat[,3] <- factor(csat[,3], levels=c(1,2,3,4),
labels=c("2012-01",
> "2012-02", "2012-03", "2012-04"))
> csat.counts <- table(csat)
>
> How do I get the satisfaction scores as a percentage per store per week? It
> must be something simple, perhaps just because the indexing of a
> 3-dimensional matrix is not very intuitive to me.
>
> Any help is highly appreciated!
>
> Kind regards,
> Patrick
>
> [[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.