Goals of this Lesson:
1) Create side-by-side boxplots via the R command (scroll to the bottom of the page for details):
boxplot()
2) Learn the R command to remove all objects:
rm(list=ls())
(Scroll to the bottom of the page for the commands to clear the screen.)
Instructions
Watch the following video and do your R3 assignment. While the video demonstration below uses a Mac, both PC and Mac users will see a similar screen layout in R.
- Create a R script to type your R commands for the question below.
- At the top of your R script, use # to
- type your name AND
- type a sentence or two to describe your quantitative variable (see the question below). It is optional to include other information such as assignment name, etc).
- Upload your R script (the extension is .R) to Canvas by the due date. No need to upload your boxplots pdf.
The video shows you how to save your boxplots diagram as a PDF so that you have a record for yourself of what you have done. However, you DO NOT need to upload your PDF into Canvas.
Important:
What the grader will do is to run your.R script and grade the boxplots generated from your .R script. So make sure your .R script works.
Here is the R3 assignment:
There is only one question in this assignment:
— Come up with a quantitative variable with two sets of data.
— Each set of data should consists of 10 to 20 data points.
— Your variable can be biology-related (but they don’t have to be) as your grader knows biology. Just make sure that your variable makes sense and use a sentence or two to describe your variable at the top of your script by using #.
— Construct two boxplots for the two sets of data on one single scale. That is, you create side-by-side boxplots on one single scale —no credits will be given if this requirement is not satisfied. You can choose vertical or horizontal boxplots. No need to do both.
— To receive full credits, Make sure your diagram of boxplots show the following:
— each boxplot has one outlier (it can be a high or low outlier)
— a chart title for the entire diagram
— labels for the horizontal and vertical axes (include unit of measurement for one of the axes)
— a label for each boxplot
Here are the arguments (inputs) to include in the command boxplot():
names Group labels which will be printed under each boxpot
xlab Label for the x axis
ylab Label for the y axis
main Title for the entire diagram
col Colors for the boxplots (see below for more details)
If you want to do horizontal boxplots, include the following argument (you also need to make sure your x label and y label make sense).
horizontal TRUE
Here is a list of colors in R:
http://www.stat.columbia.edu/~tzheng/files/Rcolor.pdf
To clear your screen in the R Console:
To clear the screen in Mac, type command + option + L
To clear the screen in Windows, type control + L
-END-