R Programming - Introduction
R Programming - Introduction
R Script
Console Files/Plots/Viewer/Packages/Help
Set the working
directory
Enter in console:
setwd(“directorypath”)
getwd() #to getaworking
Step 1: Choose suitabledirectory
location by clicking on the indicated buttondirector
To choose working
Or
Set the working
directory
Step 2: Once directory is chosen, select the more icon and choose
“set as working directory”
Resul
t
Execute pieces of code -
Run
Executing R Files –
Summary
• Run can be used to execute selected lines
• Source / Source with echo is for a whole file
• Advantages – Using Run:
• Troubleshooting /debugging
• Disadvantages – Using Run:
• For large section, console will be over populated and
messy
How
to
•Add Comments
• For single line comment, insert ‘#’ at the start of the line
• For multiple line comment, select multiple lines using cursor, then
press CTRL+Shift+C
• Or Select multiple lines using cursor, click on “Code” in menu and
select “Comment/Uncomment lines”
• Clear the environment
• To clear console, CTRL+L
• To clear environment, Single variable: Enter in console/R Script:
rm(variable)
• All variables: Enter in console/R Script: rm(list=ls())
How
to
•
Saving the workspace
• Workspace data: Workspace information is
temporary
• Workspace data is not retained after the session
• If you close the R-Session
• If you restart the computer