They make that much…

Being a CEO of a Very large corporation must be a difficult job. While I have never done it, I have taken a look at their compensation. Some argue that their pay is a bad thing and some argue that it is ok. I have to admit that I am wooed by the Entrepreneur article in the previous link.
We are only looking at the top 100 paid CEOs. If we include all 240 thousand CEOS, then the median CEO salary is not as outrageous. Today we are going to practice our R skills by looking at a little data on CEO compensation and some information on their respective companies.

Get R and R-Studio Installed

The links to R-studio can be found here. We have found that R-studio is the best way to introduce R, but it is not necessary to use R. I switch back and forth between R-studio and Sublime Text. Sublime has a package for improved interactions with R as well.

Test Case Assignment

After following the directions to create a new Rmd file. You can click the knit button at the top of the script window and it would do your analysis.

  • After clicking knit you will be prompted to save the file.
  • Save the file in a folder for this class and it will build an analysis webpage. At times I will tell you the name of the file. You will need to always save “_studentid.Rmd" at the end of your file name.
  • Now you can delete the information out of the file that was created.
  • The other key item you need to learn is the green +C button that opens up a space for R code to be written in your document.

Reading the data into R

One of the most difficult hurdles to any new software is figuring out how to get data in and out. There are many ways to do this in R and some specific material on how to get data into R from Excel.

You can assign information to an object. The information you assign to an object is almost limitless (can you say kitchen sink). To start out, we are just going to assign a text string to an object called data.dir. If you have a local download location, type in the folder of the location where you extracted the data.

data.dir = "c://m330data"
data.dir = "http://byuistats.github.io/M330/data"

With this data.dir variable defined we can read data into R. Before we read the data you might time ‘data.dir’ in the Console and see what is returned. Note a few facts in the code below

  • read.csv and file.path are functions in R.
  • stringsAsFactor is a variable in the function `read.csv’
  • by typing ?read.csv we can see what that variable does.
salary = read.csv(file.path(data.dir,"Top100_CEO.csv"),stringsAsFactors = FALSE)
company = read.csv(file.path(data.dir,"Top100_CEO_company.csv"),stringsAsFactors = FALSE)

Now you have two datasets in R that you can use to try out the functions

Taking a look at the data

In the file you have created use the functions listed in the R Code Tutorial to examine the salary and company data that we have read into R.

Here are the questions that we will address in class today. The goal is to answer them with R code.

  • How many CEOs make less than $25 million dollars?
  • What is the spread of the Top 100 CEO compensations (numerical and plot)?
  • Which company has the smallest value?
  • What is the difference between the mean and median CEO compensation?
  • Which company has the largest price to earnings ratio?
  • What is the standard deviation of the earnings ratios?