====== Working Directory ====== Getting > getwd() [1] "/home/paul/research" > setwd("Bayes") > getwd() [1] "/home/paul/research/Bayes" setwd("c:/r_data") getwd() ====== Saving Workspace ====== > save.image() ====== Command History ====== > history() # Default 25 > history(100) # Show 100 most recent lines of history > history(Inf) # Show entire saved history ====== Saving the Result of the Previous Command ====== > aVeryLongRunningFunction() # Oops! Forgot to save the result! [1] 147.6549 > x <- .Last.value # Capture the result now > x [1] 147.6549 ====== Displaying the Search Path ====== > search() Gives a list of attached packages (see library), and R objects, usually data.frames. ====== Load and attach packages ====== library(packagename) library and require load and attach add-on packages. NOTE: no quote on package name. detach(packagename) ====== Built-in Datasets ====== Find out available data set. data() Choose a specific data set from a specific package name. > data(dsname, package="pkgname") > require(graphics) > plot(pressure, xlab = "Temperature (deg C)", ylab = "Pressure (mm of Hg)", main = "pressure data: Vapor Pressure of Mercury") > plot(faithful, xlab = "eruptions", ylab = "waiting", main = "old faithful erruption and waiting ratio") {{faithful_data_graphic.png}} > data(Cars93, package="MASS") > data(package="pkgname") ====== List of Installed Packages ====== library() ====== Installing Packages ====== > install.packages("packagename") ====== Running a Script ====== > source("myScript.R")