Question: MATH 4 7 5 3 Laboratory 2 Introduction to R and Chapter 2 In this lab you will learn the basics of R . This
MATH Laboratory
Introduction to R and Chapter
In this lab you will learn the basics of R This program is free and you are encouraged to
obtain a copy for your Mac, PC or Linux machine. Install it and then download and install
R studio this is a nice front end to R and is also free
Objectives
In this lab you will learn how to:
Use the empirical rule
Use the Chebyshev rule
Transform data to z values
Find outliers using z values
Tasks
There are many IDEs integrated development environment we could use in conjunction with R however
we will use Rstudio for all of the course.
All output must be made by using an RMD document knit into an html file. Save and place in the dropbox
when completed.
Task
o Download from CANVAS the zipped data files, Dataxls
o Unzip the contents into a directory on your desktop call it LAB
o Download the file labr
o Place this file with the others in LAB
o Start Rstudio
o Open labr from within Rstudio.
o Go to the session menu within Rstudio and set working directory to where the source
files are located.
o Obtain the working directory by issuing the command getwd:
Task
o Find the file EPAGASxls inside LAB
o Open it in Excel
o Save As type CSVcomma delimitedcsv
o Use read.table read.csv or the Rstudio menu to read the data into
R or any other method available this function will already be available within the script
labr which you have opened in Rstudio.
o Obtain the first six lines of the data using head :
Task
o Make the object mpg the number of miles per gallon vector.
o If
then and
Transform the mpg variable to z and verify these
results.
o Using z find the values of mpg that are possible outliers.
o Using z find the values of mpg that defined as outliers.
o Using the lattice package construct a dotplot with colors, Redoutlier, Bluepossible
outlier. NB read the instructions in the labr file for installing the package
Task
o Make a boxplot of the mpg variable
Make the box black
Put a notch where the median goes
Put a title on the graph.
Make the plot horizontal.
o Using Chebyshevs theorem predict the proportion of data within standard deviations of
the mean of the mpg data.
o Use R to calculate the exact proportion within standard deviation of the mean.
o Does Chebyshev agree with the data?
o Now use the empirical rule, what proportion according to the rule of the data should be
within standard deviations of the mean?
o How well does it correspond?
o Is the Empirical rule valid in this case? Why?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
