r:navigating
This is an old revision of the document!
Table of Contents
Working Directory
Getting
> getwd() [1] "/home/paul/research" > setwd("Bayes") > getwd() [1] "/home/paul/research/Bayes"
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
> 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")
> data(Cars93, package="MASS")
> data(package="pkgname")
List of Installed Packages
library()
Installing Packages
> install.packages("packagename")
Running a Script
> source("myScript.R")
r/navigating.1545006786.txt.gz · Last modified: 2018/12/17 09:33 by hkimscil