Goals of this Lesson:
1) Learn to use RStudio
2) Create histograms via the R command:
hist()
Installing and Starting RStudio
Notice that the RStudio and R Console applications have different icons:
If you haven’t installed RStudio, see the download instructions on the syllabus for details.
If you use a PC, please note that RStudio has the same layout on both Macs and PCs. If you find your screen layout very different than that shown in the video, that means that you are not using the RStudio application.
To find where the RStudio is on your PC and what the screen layout looks like, watch the following video starting from the time-mark of 3:00:
https://www.youtube.com/watch?v=GAGUDL-4aVw
Instructions for the R4 assigment
Watch the following video and do your R4 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
- At the top of your R script, use # to
-
- type a sentence or two to describe your own quantitative variable (see the question below). It is optional to include other information such as assignment name, etc).
- Take a screenshot of your RStudio session showing all 4 windows —
- Script window showing your R commands
- Console window showing certain commands being executed (it’s OK if your Console window shows errors).
- Environment window showing your vector (object)
- Plot window showing your histogram
Save your screenshot as a PDF.
- Upload the following 2 items to Canvas by the due date and time.
-
- screenshot (.pdf)
- R script (the extension is .R)
-
No need to upload your histogram pdf.
(The video shows you how to save your histogram as a PDF so that you have a record for yourself. 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 histogram generated from your .R script. So make sure your .R script works!
Here is the question for the R4 assignment:
There is only one question in this assignment:
Goal: create a skewed-left histogram
Details:
Come up with a quantitative variable that is different than the one shown in the video —
— 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 #.
— You can name your variable anything (such as commute times, rainfall amount, etc) as long as it is clear what it represents (e.g. calling your variable “school” or “season” is NOT clear enough)
— Make up between 10 to 40 observations so that the histogram is roughly skewed to the left. Repeated data values (observations) are allowed.
Create a histogram with the following properties—
— the shape should be roughly skewed to the left
— the histogram should have a minimum of 4 bars but no more than 12 bars
— a chart title
— a label for the x-axis (include the unit of measurement)
Here are the arguments (inputs) to include in the command hist():
xlab Label for the x axis
main Title for the entire diagram
The following argument is optional—
breaks the number of bars you want in the histogram
(Note: R will try to accommodate your wish here but it will still use its own judgement. For example, if you say breaks = 4, R might not necessarily give you exactly 4 bars.)
-END-