Probability with R. Jane M. Horgan

Чтение книги онлайн.

Читать онлайн книгу Probability with R - Jane M. Horgan страница 22

Probability with R - Jane M. Horgan

Скачать книгу

arch2, xlab = "Architecture Semesters 1 and 2")

c03f003

      Notice also in Fig. 3.3 that there are points outside the whiskers of the boxplot in Architecture in Semester 2. These points represent cases over 1.5 box lengths from the upper or lower end of the box and are called outliers. They are considered atypical of the data in general, being either extremely low or extremely high compared to the rest of the data.

      boxplot(marks˜gendermarks)c03f004

      Notice the outlier in Fig. 3.4 in the male boxplot, a value that appears large compared to the rest of the data. You will recall that a check on the examination results indicated that this value should have been 46, not 86, and we corrected it using

      marks[34] <- 46

      boxplot(marks˜gendermarks)

c03f005

      To compare the performance of females and males in Architecture in Semester 1, write

      gender <- factor(gender, levels = c("f", "m"), labels = c("Female", "Male"))

      which changes the labels from “f ” and “m” to “Female” and “Male,” respectively. Then

      boxplot(arch1∼gender, ylab = "Marks (%)", main = "Architecture Semester 1", font.main = 1)

c03f006

      Notice the effect of using main = "Architecture Semester 1" that puts the title on the diagram. Also, the use of font.main = 1 ensures that the main title is in plain font.

      We can display plots as a matrix using the par function: par(mfrow = c(2,2)) causes the outputs to be displayed in a images array.

      par(mfrow = c(2,2)) boxplot(arch1∼gender, main = "Architecture Semester 1", font.main = 1) boxplot(arch2∼gender, main = "Architecture Semester 2", font.main = 1) boxplot(prog1∼gender, main = "Programming Semester 1", font.main = 1) boxplot(prog2∼gender, main = "Programming Semester 2", font.main = 1)

c03f007

      To undo a matrix‐type output, write

      par(mfrow = c(1,1))

      which restores the graphics output to the full screen.

      A histogram is a graphical display of frequencies in categories of a variable and is the traditional way of examining the “shape” of the data.

      hist(prog1, xlab ="Marks (%)", main = "Programming Semester 1")

c03f008

      hist(prog1, xlab = "Marks (%)", main = "Programming Semester 1", breaks = 5)

c03f009

      par (mfrow = c(2,2)) hist(arch1, xlab = "Architecture", main = "Semester

Скачать книгу