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
ZIP
file for this class, then go ahead and do so. - Open the Project file
week1.Rproj
from withinRStudio
. - Once everything loads, use the
File
tab (in the lower right ofRStudio
) to click onweek1-demo.R
to 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-A
on a mac) to highlight the whole script. - Use
control-enter
to run it (or click theRun
button at the top of the file window). - Use the data browser (i.e., from the
Environment
tab in the upper right) to view thecourses
dataframe and briefly discuss what you see there. - Now highlight just lines 1-56 and run those. What happened?
- In the
Console
window (bottom left ofRStudio
), typecourses
at the command prompt and then hitEnter
and 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
R
script using theFile/New File
menu item. - Copy and paste lines 1-56 from
week1-demo.R
into the new script. - Save it as
group_work.R
in your Week 1 folder. Notice that it appears in the file browser (in theFiles
tab in the bottom right). - Close the script by clicking the
x
on the script tab (in the top of the upper left tab inRStudio
), and then re-open it using the lower rightFiles
listing. - 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.