Ch. 4 | Exercise 1

Chapter 4 | Exercise 1

Compute the proportions of each level in the factor subj from the data set sent. Express them as percentages.

First, load the package and the data:

> library(Rling) > data(sent)

Create a frequency table (one of possible options):

> subjects <- table(sent$subj) > subjects Abstr Animal Hum MatObj 5 1 11 3

Compute the proportions:

> prop.table(subjects) Abstr Animal Hum MatObj 0.25 0.05 0.55 0.15

Express the proportions as percentages:

> prop.table(subjects)*100 Abstr Animal Hum MatObj 25 5 55 15