Table of Contents

Using R

Intro

R is a statistical mathematics tool similar to Matlab. However, it is free and doesn't need a license server, which is why we are investigating using it for BodyTrack. Here are some of my notes on using it.

Easy Stuff

Vectors

> x <- c(1,2,4)
> length(x)
[1] 3
> x[1:length(x)-1]
[1] 1 2
> rep(1,10)
[1] 1 1 1 1 1 1 1 1 1 1

Graphing

getwd()						#Shows current directory
setwd("~/Downloads")				#Sets current directory
#Read in and graph csv
tree <- read.csv(file="trees91.csv",sep=",",head=TRUE)
plot(tree$STBM,tree$LFBM,
+ main="Rel Stem Leaf",
+ xlab="Stem Biomass",
+ ylab="Leaf Biomass")

Running A Script

#This runs the script from the command line window
source("/path/to/filename.R")

Medium

Convolution

A little bit trickier because R has some weird ways of doing things…Does convolution using FFT and defaults to circular convolution!

x <- c(1,2,3,4,5,6,7)
y <- c(-1,1)
convolve(x,y,type="open")
help() #great for documentation!

Tutorials

Hard

Using External C Functions