Using RStudio
Week 1 In-class Collaboration
This in-class exercise is intended to develop familiarity with the RStudio interface and some useful functions in R.
1 Instructions
You’ll work in groups. Choose one person to share screen within your group, and walk through the instructions below.
To prepare, do the following:
- If you haven’t already downloaded the
ZIPfile for this class, then go ahead and do so. - Open the Project file
week1.Rprojfrom withinRStudio. - Once everything loads, use the
Filetab (in the lower right ofRStudio) to click onweek1-demo.Rto bring the script to the editing window (in the upper left). This is the script we just talked through in the live session.
2 Work through these in your group
- Use
control-A(command-Aon a mac) to highlight the whole script. - Use
control-enterto run it (or click theRunbutton at the top of the file window). - Use the data browser (i.e., from the
Environmenttab in the upper right) to view thecoursesdataframe and briefly discuss what you see there. - Now highlight just lines 1-56 and run those. What happened?
- In the
Consolewindow (bottom left ofRStudio), typecoursesat the command prompt and then hitEnterand discuss what happens. - Type
summary(courses)in the command prompt and discuss - Type
names(courses)in the command prompt and discuss
Tip
Use of the command prompt
The command prompt in the Console is only used for quick inspection of data, and items 5-7 above are are three common ways to do that.
- Create a new
Rscript using theFile/New Filemenu item. - Copy and paste lines 1-56 from
week1-demo.Rinto the new script. - Save it as
group_work.Rin your Week 1 folder. Notice that it appears in the file browser (in theFilestab in the bottom right). - Close the script by clicking the
xon the script tab (in the top of the upper left tab inRStudio), and then re-open it using the lower rightFileslisting. - Use the project browser (far top right of the window) to close the project, and then re-open it. The drop-down there allows you to quickly switch between projects.