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.
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.
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.
knit
you will be prompted to save the file.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’?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
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.