#Set working directory setwd("/Users/Shared/WD/Rdirectory") #Change this pathname to wherever you saved the example data files #Print current working directory getwd() #Example 1 contains simulated weights (lbs) of men #Read data file into R as a vector example1 = scan("example1.dat") #Print data example1 #Calculate the sample mean and assign it to an object named xbar xbar=mean(example1) #Print xbar xbar #You do not have to assign the function to an object to see the value sd(example1) #Example 2 contains simulated average daily temperatures in State College, PA during May and November #Read data file into R as a data frame example2 = read.table("example2.csv", header=T, sep=",") #Print data example2 #To print multiple graphs on a page, split the plotting window into 2 rows and 2 columns par(mfrow=c(2,2)) #Plot a histogram of May hist(example2$may) #Plot a histogram of November hist(example2$november) #Note that R is case-sensitive. Both of the following commands will produce errors due to case: Hist(example2$may) #Error in eval.with.vis(expr, envir, enclos) : could not find function "Hist" hist(example2$May) #Error in hist.default(example2$May) : 'x' must be numeric #Because Hist(example2$may) produced an error, R stopped running code from this program. hist(example2$May) therefore was not sourced. I copied the error reported by R for your reference. By the reported error, it is not clear that the problem is simply a matter of case; it is only clear that there is a problem.