




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





This document describes how to accomplish the following tasks.
Scores on Test #2 - Males 42 Scores: Average = 73. 84 88 76 44 80 83 51 93 69 78 49 55 78 93 64 84 54 92 96 72 97 37 97 67 83 93 95 67 72 67 86 76 80 58 62 69 64 82 48 54 80 69
Raw Data → becomes → Organized
Males Scores Frequency 30 - 39 1 40 - 49 3 50 - 59 5 60 - 69 9 70 - 79 6 80 - 89 10 90 - 99 8 Then we created a relative and cumulative frequency table from this.
Frequency Distribution: Males
Scores Frequency 30 - 39 1 40 - 49 3 50 - 59 5 60 - 69 9 70 - 79 6 80 - 89 10 90 - 99 8
Relative Frequency Distribution: Males Relative Scores Frequency 30 - 39 2.4% 40 - 49 7.1% 50 - 59 11.9% 60 - 69 21.4% 70 - 79 14.3% 80 - 89 23.8% 90 - 99 19.0%
Cumulative Frequency Distribution: Males Cumulative Scores Frequency less than 40 1 less than 50 4 less than 60 9 less than 70 18 less than 80 24 less than 90 34 less than 100 42
Here we see how to do these tasks with R. We’ll start by importing the data into R. Suppose the data is in an Excel file saved as a .CSV file named Excel-Data.csv that looks like
This is imported into R using the read.table command.
male female data <- read.table("Excel-Data.csv",header=TRUE,sep=",") male scores <- male female data$Males
Scores on Test #2 - Males 42 Scores: Average = 73. 84 88 76 44 80 83 51 93 69 78 49 55 78 93 64 84 54 92 96 72 97 37 97 67 83 93 95 67 72 67 86 76 80 58 62 69 64 82 48 54 80 69
Raw Data → becomes → Histogram
Here, we’ll let R create the histogram using the hist command. You can define your own classes by creating a list of class boundaries and using the breaks = command. You can also add a title (main =), a label (xlab =), and color (col =).
Suppose we have data for cricket chirps per minute and temperature in degrees Fahrenheit in an Excel file saved in .CVS format that looks like
We have R create a scatterplot with the plot(x,y) command and put in the line of best fit with the abline command.
Simple scatterplot:
Some customization and a line of best fit:
Mon <- c(68, 84, 93, 68, 70)
Monday Tuesday Wednesday 68 59 55 84 72 66 93 78 77 68 91 88 70 90 99
You can combine lists like the one described above into a table using the matrix command. Setting this up takes a little effort and the usage is depicted in the screenshot on the next page. Everything in red is typed by the user. Everything in blue is output to the console.