58 lines
1.3 KiB
R
58 lines
1.3 KiB
R
|
library(MASS)
|
||
|
painters
|
||
|
painters$School
|
||
|
school = painters$School
|
||
|
school.freq = table(school)
|
||
|
school.freq
|
||
|
cbind(school.freq)
|
||
|
head(painters)
|
||
|
composition = painters$Composition
|
||
|
composition.freq = table(composition)
|
||
|
cbind(composition.freq)
|
||
|
school
|
||
|
school.freq
|
||
|
school.freq[1]
|
||
|
help(max)
|
||
|
school[,][1]
|
||
|
school[1,][1]
|
||
|
school[1][1]
|
||
|
school[1]
|
||
|
school.freq[1,]
|
||
|
school.freq[1]
|
||
|
school.freq[1][1]
|
||
|
school.freq[1]
|
||
|
help(typeof)
|
||
|
typeof(school.freq[1])
|
||
|
max(school.freq)
|
||
|
max(school)
|
||
|
max(school.freq)
|
||
|
school.relfreq = school.freq / nrow(painters)
|
||
|
school.relfreq
|
||
|
settings = options(digits=1)
|
||
|
school.relfreq
|
||
|
options(settings)
|
||
|
cbind(school.relfreq)
|
||
|
composition.freq
|
||
|
composition.relfreq = composition.freq / nrow(composition)
|
||
|
composition.relfreq = composition.freq / nrow(painters)
|
||
|
composition.relfreq
|
||
|
cbind(composition.relfreq)
|
||
|
# bar graph exercise
|
||
|
library(MASS)
|
||
|
school = painters$School
|
||
|
school.freq = table(school)
|
||
|
barplot(school.freq)
|
||
|
colors = c("red", "yellow", "green", "violet", "orange", "blue", "pink", "cyan")
|
||
|
barplot(schools.freq, col=colors)
|
||
|
barplot(school.freq, col=colors)
|
||
|
composition = painters$Composition
|
||
|
composition.freq = table(composition)
|
||
|
count.fields(composition.freq)
|
||
|
ncol(composition.freq)
|
||
|
composition.freq
|
||
|
nrow(composition.freq)
|
||
|
nrow(school.freq)
|
||
|
colors
|
||
|
barplot(composition.freq, col=colors)
|
||
|
q()
|