1

I have read an CSV file from a questionnaire with many non-numeric, nominal values, e.g, country codes, computer skills (Expert, Intermediate, Beginner), … via read.csv

I want to have the percentages of each answer for each questions, i.e. , similar to a frequency table given by summary, sorted by occurrences from high to low. Later, I also want to do cross-tabulation, e.g., country with computer skills.

summary(data) gives me almost what I want, i.e. it gives me a frequency table of the answers, but the frequencies are

  1. Not ordered by frequency but by variable
  2. Are not percentages.

prop.table should give percentage tables, but it works only with numeric values.

Is there any easy way? Which function can I use?

casperOne
  • 73,706
  • 19
  • 184
  • 253
Matthias
  • 11
  • 2
  • 1
    Go read [this](http://stackoverflow.com/q/5963269/324364) question on how to produce a reproducible example, and then edit your question accordingly. – joran Mar 12 '12 at 01:06

1 Answers1

0

This might get you started. It provides percentages of records in each of three categories for a single variable.

dat <- c("Expert", "Intermediate", "Beginner", "Expert", "Expert", "Beginner", "Intermediate", "Intermediate", "Intermediate", "Beginner", "Beginner", "Beginner")

numeric.dat <- as.numeric(factor(dat , levels = c("Beginner","Intermediate","Expert")))

zzz <- table(numeric.dat)

prop.table(zzz)
Mark Miller
  • 12,483
  • 23
  • 78
  • 132