The Workspace is the R working environment which contains, user-defined objects. The object can be lists, vectors, matrices, data frames, functions.
Note: The following are the different ways to specify the path on Windows –
# R Accepts Unix style path specification as below
#R sees a single back slash as an escape character, hence for Windows style specification you needs to specify the path as below
The following are the list of commands to manage your workspace. As you enter the commands you can use the Up and Down arrow keys to scroll through the command history.
1. getwd() # Get current working directory
2. setwd(“C:/RWorkspace”) # Set current working directory
3. ls() # List the objects in the current workspace
4. help(“ggplot2”) # Display info on the search string. In this case ggplot2.
5. options() # Display the options set for the current session
6. history() # Display last 25 commands
7. history(max.show=Inf) # Display all previous commands
8. savehistory(file=”MyFile”) # Default file is “.Rhistory”
9. loadhistory(file=”MyFile”) # Default file is “.Rhistory”
10. save.image() # Save the workspace to the default “.RData”
11. save(x,y, file=”MyFile.RData”) # Save specific object(s) to a file. “x” and “y” are objects
12. load(“MyFile.RData”) # Load the workspace into the current session
13. library(“packagename”) # Loads installed packages. For ex. ggplot2, Rcmdr.
14. q() # Quit R with a prompt to save the workspace
Note that R is case-sensitive, and assumes the current working directory if path is not specified.