Introduction to Statistics (MAT/SST 115.03 2008S)

R notes for Activity 27-2: Governors' Salaries

You can load the data with

StateData = read.csv("/home/rebelsky/Stats115/Data/Governors05.csv")

Since that data set turns out to have many more columns than are reported in the table on p. 554, it's useful to see a quick summary of the data.

> summary(StateData)
        State    Eastwest        Region   Median.Housing.Value Median.Household.Income
 Alabama   : 1   east:26   Midwest  :12   Min.   : 70700       Min.   :32397          
 Alaska    : 1   west:24   Northeast: 9   1st Qu.: 88475       1st Qu.:38414          
 Arizona   : 1             South    :16   Median :108200       Median :42621          
 Arkansas  : 1             West     :13   Mean   :117990       Mean   :43172          
 California: 1                            3rd Qu.:139825       3rd Qu.:47980          
 Colorado  : 1                            Max.   :272700       Max.   :56409          
 (Other)   :44                                                                        
 Min.   : 70000  
 1st Qu.: 95340  
 Median :111352  
 Mean   :117984  
 3rd Qu.:132161  
 Max.   :179000  

27-2 b. Scatterplots

You can plot those data with

plot(StateData$Median.Housing.Value, StateData$Governor.Salary)

27-2 d. Correlation Coefficient

We are fortunate that these data do not include any NA values. Hence, we can compute the correlation coeficient directly.

cor(StateData$Median.Housing.Value, StateData$Governor.Salary)

27-2 f. Changing Salaries

It's been a long time since we've updated a frame. We can use fix to bring up the data editor on that frame.


After changing the appropriate cell, click somewhere else in the grid before closing the edit window. Your changes are not saved until you close the window. (You also cannot continue working in R until you close the window.)

At least in the Unix version of R, it seems that you change a cell by deleting the old contents and then enter the new contents. The new salary should be 194780.

You may want to check to make sure that the salary was, indeed, updated.


Creative Commons License

Samuel A. Rebelsky,

Copyright (c) 2007-8 Samuel A. Rebelsky.

This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 License. To view a copy of this license, visit or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.