Uploading Simple Data - Plus Simple Analysis with R Software

Let's say you're given the follow table of make heights:

Name            Inches 
Jake     70 
Bill 64.5 
Rich 72 
J-Bob 68 
Lance 69 
Lou 70 
Ryan73.5 

And say we want to find the mean, median, mode, variance, standard deviation and plot a histogram. You could calculate all this by hand, and plot the histogram by hand. But let's use R Software. 

Inputting (uploading?) the data. 
height<-c(70,64.5,72,68,69,70,73.5)
This script creates a vector of 7 observations.

If you type 'height' in R, it should spit out the following.
[1] 70.0 64.5 72.0 68.0 69.0 70.0 73.5 

Mean
mean(height)
[1] 69.57143

Median 
median(height)
[1] 70

tabheight<-tabulate(height)
heightmode<-which(tabheight == max(tabheight))
heightmode
[1] 70

Variance
var(height)
[1] 8.369048

Standard Deviation 
sd(height)
[1] 2.892931

Histogram
hist(height)



A slightly more detailed, and well-labeled histogram. 
hist(height,20,main="Histogram for Peole's Height",xlab="Height of Dudes",ylab="Frequency")
(it even carried over my misspellings) 









Comments