problem-4.12
problem-4.12
As the data is stored in a list, the boxplots are produced
without any additional work:
> boxplot(u2)
However, we see that the titles are not legible. We can plot
the titles along the side and give enough room for them to print
with the commands:
> par(mar=c(5,15,4,2)) # increase to 15 from default 4
> boxplot(u2, las=2, horizontal=TRUE)
> par(mar=c(5,4,4,2)) # restore to original settings
The mean and median for each album can be found using
sapply():
> sapply(u2,mean)
> sapply(u2,median)
Comparisons can be made by subtracting the two. Finally, after
unlisting we can sort to find the lengths:
> rev(sort(unlist(u2)))[1:3]
Zooropa. Lemon Zooropa. Zooropa
416 390
Rattle & Hum. All I Want Is You
390