Friday, April 5, 2013

An Annotated R History Log - Part 3

data(package="ggplot2") - show the datasets in the package ggplot2.

require(ggplot2) - import the package into the workspace. Then you can get at the datasets like this:

diamonds - print the diamonds dataset out.

list.files() - list files in the working directory.

getwd() - what is the working directory.

setwd(val) set the working directory.

read.csv("unemp.csv") - read the comma separated file unemp.csv from the workspace (would be better off assigning this to a variable with <-

unemp[x] - show the x entry of dataset unemp. 1 indexed.

t(unemp) - transpose the unemp dataset.

sub() - perform text substitution using regular expressions. First match only. gsub for global.

plot(ts(unemp), ylab="Live Register", xlab="Date", main="Irish Unemployment Numbers", type="o")
plot a time series plot of the unemp dataset. x and y axis labels are given along with a title. The chart type is o for overwrite (symbols with lines overwritten)

summary(unemp) - provide summary information on the unemp dataset. min, max median etc.



No comments:

Post a Comment