Answered step by step
Verified Expert Solution
Question
1 Approved Answer
8 . This exercise relates to the College data set, which can be found in the fle College.csv on the book website. It contains a
This exercise relates to the College data set, which can be found in
the fle College.csv on the book website. It contains a number of
variables for diferent universities and colleges in the US The
variables are
Private : Publicprivate indicator
Apps : Number of applications received
Accept : Number of applicants accepted
Enroll : Number of new students enrolled
Topperc : New students from top of high school class
Topperc : New students from top of high school class
FUndergrad : Number of fulltime undergraduates
PUndergrad : Number of parttime undergraduates
Exercises
Outstate : Outofstate tuition
Room.Board : Room and board costs
Books : Estimated book costs
Personal : Estimated personal spending
PhD : Percent of faculty with PhDs
Terminal : Percent of faculty with terminal degree
SFRatio : Studentfaculty ratio
perc.alumni : Percent of alumni who donate
Expend : Instructional expenditure per student
Grad.Rate : Graduation rate
Before reading the data into R it can be viewed in Excel or a text
editor.
a Use the read.csv function to read the data into R Call the
loaded data college. Make sure that you have the directory set
to the correct location for the data.
b Look at the data using the View function. You should notice
that the frst column is just the name of each university. We dont
really want R to treat this as data. However, it may be handy to
have these names for later. Try the following commands:
rownamescollege college
Viewcollege
You should see that there is now a row.names column with the
name of each university recorded. This means that R has given
each row a name corresponding to the appropriate university. R
will not try to perform calculations on the row names. However,
we still need to eliminate the frst column in the data where the
names are stored. Try
college college
Viewcollege
Now you should see that the frst data column is Private. Note
that another column labeled row.names now appears before the
Private column. However, this is not a data column but rather
the name that R is giving to each row.
c i Use the summary function to produce a numerical summary
of the variables in the data set.
ii Use the pairs function to produce a scatterplot matrix of
the frst ten columns or variables of the data. Recall that
you can reference the frst ten columns of a matrix A using
A:
Statistical Learning
iii. Use the plot function to produce sidebyside boxplots of
Outstate versus Private.
iv Create a new qualitative variable, called Elite, by binning
the Topperc variable. We are going to divide universities
into two groups based on whether or not the proportion
of students coming from the top of their high school
classes exceeds
Elite repNo nrowcollege
Elitecollege$Topperc "Yes"
Elite asfactorElite
college data.framecollege Elite
Use the summary function to see how many elite universities there are. Now use the plot function to produce
sidebyside boxplots of Outstate versus Elite.
v Use the hist function to produce some histograms with
difering numbers of bins for a few of the quantitative variables. You may fnd the command parmfrow c
useful: it will divide the print window into four regions so
that four plots can be made simultaneously. Modifying the
arguments to this function will divide the screen in other
ways.
vi Continue exploring the data, and provide a brief summary
of what you discover
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started