Rcmdr - Assignment #1 - Making a histogram with R Commander - Due ________
Hard copy submissions will be accepted only in class on the due date. Any early or late submissions must be submitted in Blackboard (you can also submit it in Blackboard on the day it is due.) (I may be changing this to Webassign.)
You will need to resubmit it as a Word (.doc or .docx), Word Perfect (.wpd), or Rich Text format (.rtf).
Your name must be at the top of every page that you submit.
You should be submitting THREE graphs.
You must work independently on your R assignments. You may ask your fellow classmates questions, but each student must do their own assignment.
(These instructions assume you have already installed R and Rcmdr.)
1. From my website http://faculty.umf.maine.edu/sarah.hardy/public.www/
(Google Sarah Hardy umf and it should be the first thing that pops up)
Download the 2010 MPG data in the comma-delimited 2010MPGcsv.csv file and save it somewhere where you will know where it is.
There is also a video of this assignment - the link is on my web page ( http://www.youtube.com/watch?v=wWeiKMHx31U ) - the assignment part is at the end of the video about installing R..
2. Open R by clicking on the R 2.11.1 icon.
3. Open R Commander by selecting Packages (from menu along the top), and then Load Packages and then scrolling down in the list that pops up and selecting Rcmdr.
*If this is the first time you have used Rcmdr it a pop-up will come up and tell you that additional packages need to be installed.*
When it says: ...
Install these packages? Select Yes.
On the next pop-up screen say OK. Then just be patient because it takes awhile.
4. Select Data, then Import Data, then from textfile, clipboard or URL. .
In the next pop-up ...
It will prompt you for a name, in the box provided type
mpg
Then be sure to click “Commas” under Field Separator.
Then in the next pop-up window select your 2010MPGcsv file from the directory where you saved it.
5. The select Graphs, then select Histograms.
6. Under Variables(select one) highlight citympg and click OK.
7. The histogram will appear in the regular R window which may be minimized at this point.
8. PCs - Right-click on the graph, and select Copy as metafile. Then paste it into a Word document.
Macs - Open a Word document, go back to the graph window, click on Edit (in the top row across the screen) > Copy, then go back to your Word document, click on Edit (in the top row across the screen) > Paste.
9. Make a second histogram and in the second histogram select percentages (instead of the default which is Frequency counts). Also paste this histogram into your Word document.
10. How do the two graphs compare? (Be sure and type your answer to this question into your document for full credit).
11. For the third graph you will make another graph exactly like the second, but with a title and labels on the graph
To do so go up to the script window with your cursor...
Remove the last parentheses from the last line so that it looks like this:
Hist(mpg$citympg, scale="percent", breaks="Sturges", col="darkgray",
...add the following line:
xlab="2010 City MPG",main="Put your name here")
...then highlight both lines together and hit the Submit button beneath the script window on the right side .
Alternatively, put you cursor anywhere on either of the two lines, right click and select Submit.
See Youtube video for demonstration.
12. Close R - it will come up and ask you if you want to save your workspace - say Yes. Then next time when you open R the mpg dataset will still be available to you and you won’t have to re-import it for the second Rcmdr assignment.
NOTE: It is very important to get all the commas and quotation marks in the right place or it will not work!