rBasics.pdf
-
Upload
carlos-tibi-morales -
Category
Documents
-
view
3 -
download
0
Transcript of rBasics.pdf
Computational Finance and Risk Management
R Programmingfor Quantitative Finance
Guy YollinApplied Mathematics
University of Washington
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 1 / 53
Outline
1 R language overview and history
2 R language references
3 Short R Tutorial
4 The R help system
5 Web resources for R
6 IDE editors for R
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 2 / 53
Lecture references
J. Adler.R in a Nutshell: A Desktop Quick Reference.O’Reilly Media, 2010.
Chapters 1-3
W. N. Venables and D. M. Smith.An Introduction to R.2013.
Sections 1-3
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 3 / 53
Outline
1 R language overview and history
2 R language references
3 Short R Tutorial
4 The R help system
5 Web resources for R
6 IDE editors for R
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 4 / 53
The R programming language
R is a language and environment for statistical computing andgraphics
R is based on the S language originally developed by John Chambersand colleagues at AT&T Bell Labs in the late 1970s and early 1980s
R (sometimes called “GNU S" ) is free open source software licensedunder the GNU general public license (GPL 2)
R development was initiated by Robert Gentleman and Ross Ihaka atthe University of Auckland, New Zealand in the 1990s
R is formally known as The R Project for Statistical Computingwww.r-project.org
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 5 / 53
Strengths of the R programming language
Data manipulation
Data analysis
Statistical modeling
Data visualization1.
01.
52.
02.
53.
03.
54.
0
HAM1
EDHEC LS EQ
SP500 TR
Cum
ulat
ive
Ret
urn
HAM1 Performance
−0.
10−
0.05
0.00
0.05
Mon
thly
Ret
urn
Jan 96 Jan 97 Jan 98 Jan 99 Jan 00 Jan 01 Jan 02 Jan 03 Jan 04 Jan 05 Jan 06 Dec 06
Date
−0.
4−
0.3
−0.
2−
0.1
0.0
Dra
wdo
wn
Plot from the PerformanceAnalytics package
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 6 / 53
S language implementations
R is the most recent and full-featuredimplementation of the S language
Original S - AT & T Bell Labs
S-PLUS (S plus a GUI)Statistical Sciences, Inc.†Mathsoft, Inc.Insightful, Inc.Tibco, Inc.
R - The R Project for StatisticalComputing Figure from The History of S and R, John Chambers, 2006
†Founded by UW Professor Doug Martin, CompFin Program DirectorGuy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 7 / 53
R timeline
1976 2011
Work on S
Version 1
Exponential
growth of
R Users and
R packages
1993
StatSci Licenses S
1999
John Chambers
1998 ACM Software Award
2010
R & R
Given ASA
Statistical Computing
and Graphics Award
1997
Modern Applied Statistics
with S-PLUS
2nd Edition
2004
R 2.0.0
1984
S: An Interactive Envirnoment for
Data Analysis and Graphics
(Brown Book)1988
The New S Language
Written in C
(Blue Book)
1993
R on Statlib
1991
Statistical Models in S
(white book)
S3 methods
1999
Modern Applied Statistics
with S-PLUS
3rd Edition
(S+ 2000, 5.x)
(R complements)
1997
R on CRAN
GNU Project
2002
Modern Applied Statistics
with S
4th Edition
(S+ 6.x, R 1.5.0)
1988
S-PLULS
developed by
Statistical Sciences, Inc.
2001
R 1.4.0
(S4)
1998
Programming with Data
(Green Book)
(S+ 5.x)
1994
Modern Applied Statistics
with S-PLUS
2000
R 1.0.0
(S3)
S era S-PLUS era R era
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 8 / 53
Recognition of software excellence
Association for ComputingMachineryJohn Chambers received the 1998ACM Software System Award
Dr. Chambers’ workwill forever alter theway people analyze,visualize, andmanipulate data
American StatisticalAssociationRobert Gentleman and RossIhaka received the 2009 ASAStatistical Computing andGraphics Award
In recognition for theirwork in initiating the RProject for StatisticalComputing
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 9 / 53
Outline
1 R language overview and history
2 R language references
3 Short R Tutorial
4 The R help system
5 Web resources for R
6 IDE editors for R
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 10 / 53
Essential web resources
An Introduction to RW.N. Venables, D.M. SmithR Development Core Team
R Reference Card 2.0Baggott & Short
R Reference Cardby Tom Short, EPRI Solutions, Inc., [email protected] 2005-07-12Granted to the public domain. See www.Rpad.org for the source and latestversion. Includes material from R for Beginners by Emmanuel Paradis (withpermission).
Help and basicsMost R functions have online documentation.help(topic) documentation on topic?topic id.help.search("topic") search the help systemapropos("topic") the names of all objects in the search list matching
the regular expression ”topic”help.start() start the HTML version of helpstr(a) display the internal *str*ucture of an R objectsummary(a) gives a “summary” of a, usually a statistical summary but it is
generic meaning it has different operations for different classes of als() show objects in the search path; specify pat="pat" to search on a
patternls.str() str() for each variable in the search pathdir() show files in the current directorymethods(a) shows S3 methods of amethods(class=class(a)) lists all the methods to handle objects of
class aoptions(...) set or examine many global options; common ones: width,
digits, errorlibrary(x) load add-on packages; library(help=x) lists datasets and
functions in package x.attach(x) database x to the R search path; x can be a list, data frame, or R
data file created with save. Use search() to show the search path.detach(x) x from the R search path; x can be a name or character string
of an object previously attached or a package.
Input and outputload() load the datasets written with savedata(x) loads specified data setsread.table(file) reads a file in table format and creates a data
frame from it; the default separator sep="" is any whitespace; useheader=TRUE to read the first line as a header of column names; useas.is=TRUE to prevent character vectors from being converted to fac-tors; use comment.char="" to prevent "#" from being interpreted asa comment; use skip=n to skip n lines before reading data; see thehelp for options on row naming, NA treatment, and others
read.csv("filename",header=TRUE) id. but with defaults set forreading comma-delimited files
read.delim("filename",header=TRUE) id. but with defaults setfor reading tab-delimited files
read.fwf(file,widths,header=FALSE,sep="�",as.is=FALSE)read a table of f ixed width f ormatted data into a ’data.frame’; widthsis an integer vector, giving the widths of the fixed-width fields
save(file,...) saves the specified objects (...) in the XDR platform-independent binary format
save.image(file) saves all objects
cat(..., file="", sep=" ") prints the arguments after coercing tocharacter; sep is the character separator between arguments
print(a, ...) prints its arguments; generic, meaning it can have differ-ent methods for different objects
format(x,...) format an R object for pretty printingwrite.table(x,file="",row.names=TRUE,col.names=TRUE,
sep=" ") prints x after converting to a data frame; if quote is TRUE,character or factor columns are surrounded by quotes ("); sep is thefield separator; eol is the end-of-line separator; na is the string formissing values; use col.names=NA to add a blank column header toget the column headers aligned correctly for spreadsheet input
sink(file) output to file, until sink()Most of the I/O functions have a file argument. This can often be a charac-ter string naming a file or a connection. file="" means the standard input oroutput. Connections can include files, pipes, zipped files, and R variables.On windows, the file connection can also be used with description ="clipboard". To read a table copied from Excel, usex <- read.delim("clipboard")To write a table to the clipboard for Excel, usewrite.table(x,"clipboard",sep="\t",col.names=NA)For database interaction, see packages RODBC, DBI, RMySQL, RPgSQL, andROracle. See packages XML, hdf5, netCDF for reading other file formats.
Data creationc(...) generic function to combine arguments with the default forming a
vector; with recursive=TRUE descends through lists combining allelements into one vector
from:to generates a sequence; “:” has operator priority; 1:4 + 1 is “2,3,4,5”seq(from,to) generates a sequence by= specifies increment; length=
specifies desired lengthseq(along=x) generates 1, 2, ..., length(x); useful for for loopsrep(x,times) replicate x times; use each= to repeat “each” el-
ement of x each times; rep(c(1,2,3),2) is 1 2 3 1 2 3;rep(c(1,2,3),each=2) is 1 1 2 2 3 3
data.frame(...) create a data frame of the named or unnamedarguments; data.frame(v=1:4,ch=c("a","B","c","d"),n=10);shorter vectors are recycled to the length of the longest
list(...) create a list of the named or unnamed arguments;list(a=c(1,2),b="hi",c=3i);
array(x,dim=) array with data x; specify dimensions likedim=c(3,4,2); elements of x recycle if x is not long enough
matrix(x,nrow=,ncol=) matrix; elements of x recyclefactor(x,levels=) encodes a vector x as a factorgl(n,k,length=n*k,labels=1:n) generate levels (factors) by spec-
ifying the pattern of their levels; k is the number of levels, and n isthe number of replications
expand.grid() a data frame from all combinations of the supplied vec-tors or factors
rbind(...) combine arguments by rows for matrices, data frames, andothers
cbind(...) id. by columns
Slicing and extracting dataIndexing listsx[n] list with elements nx[[n]] nth element of the listx[["name"]] element of the list named "name"x$name id.Indexing vectorsx[n] nth elementx[-n] all but the nth elementx[1:n] first n elementsx[-(1:n)] elements from n+1 to the endx[c(1,4,2)] specific elementsx["name"] element named "name"x[x > 3] all elements greater than 3x[x > 3 & x < 5] all elements between 3 and 5x[x %in% c("a","and","the")] elements in the given setIndexing matricesx[i,j] element at row i, column jx[i,] row ix[,j] column jx[,c(1,3)] columns 1 and 3x["name",] row named "name"Indexing data frames (matrix indexing plus the following)x[["name"]] column named "name"x$name id.
Variable conversionas.array(x), as.data.frame(x), as.numeric(x),
as.logical(x), as.complex(x), as.character(x),... convert type; for a complete list, use methods(as)
Variable informationis.na(x), is.null(x), is.array(x), is.data.frame(x),
is.numeric(x), is.complex(x), is.character(x),... test for type; for a complete list, use methods(is)
length(x) number of elements in xdim(x) Retrieve or set the dimension of an object; dim(x) <- c(3,2)dimnames(x) Retrieve or set the dimension names of an objectnrow(x) number of rows; NROW(x) is the same but treats a vector as a one-
row matrixncol(x) and NCOL(x) id. for columnsclass(x) get or set the class of x; class(x) <- "myclass"unclass(x) remove the class attribute of xattr(x,which) get or set the attribute which of xattributes(obj) get or set the list of attributes of obj
Data selection and manipulationwhich.max(x) returns the index of the greatest element of xwhich.min(x) returns the index of the smallest element of xrev(x) reverses the elements of xsort(x) sorts the elements of x in increasing order; to sort in decreasing
order: rev(sort(x))cut(x,breaks) divides x into intervals (factors); breaks is the number
of cut intervals or a vector of cut points
Definitely obtain these PDF files from the R homepage or a CRAN mirrorGuy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 11 / 53
Introductory texts
R in a Nutshell: A DesktopQuick Reference
Joseph AdlerO’Reilly Media, 2009
A Beginner’s Guide to RZuur, Ieno, MeestersSpringer, 2009
Both texts available online through UW libraryGuy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 12 / 53
Introductory texts
R in ActionRobert KabacoffManning Publications, 2011
The Art of R ProgrammingNorman MatloffNo Starch Press, 2011
A T O U R O F S T A T I S T I C A L S O F T W A R E D E S I G N
N O R M A N M A T L O F F
T H E
A R T O F R
P R O G R A M M I N G
T H E
A R T O F R
P R O G R A M M I N G
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 13 / 53
Statistics with R
Introductory Statistics with R2nd Edition
P. DalgaardSpringer, 2008
Modern Applied Statisticswith S, 4th Edition
Venables and RipleySpringer, 2002
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 14 / 53
Experience with other statistical computing languages
For those with experience in MATLAB, David Hiebeler has created aMATLAB/R cross reference document:
http://www.math.umaine.edu/~hiebeler/comp/matlabR.pdf
For those with experience in SAS, SPSS, or Stata, Robert Muenchen haswritten R books for this audience:
http://r4stats.com
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 15 / 53
Outline
1 R language overview and history
2 R language references
3 Short R Tutorial
4 The R help system
5 Web resources for R
6 IDE editors for R
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 16 / 53
Interacting with R
R is an interpreted language†
An R interpreter must be running in order to evaluate R commands orexecute R scripts
RGui which includes an R Console windowRStudio which includes an R Console window
†http://en.wikipedia.org/wiki/Interpreted_languageGuy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 17 / 53
R expression evaluation
R expressions are processed via R’s Read-eval-print loop †:
†http://en.wikipedia.org/wiki/Read-eval-print_loopGuy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 18 / 53
Interacting with the RGui
The RGui is an interactive commanddriven environment:
Type R commands (expressions)into the R Console
Copy/Paste multiple Rcommands into the R ConsoleSource an R script
An R script is simply a textfile of multiple R commands
Commands entered interactively into the R console
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 19 / 53
Interacting with RStudio
The RStudio is an IntegratedDevelopment Environment (IDE) R:
Embedded R ConsoleRStudio runs an R interpreterautomatically
Program editor for R
Plot window
File browser
Integrated version control
R debugger
RStudio includes an embedded R Console
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 20 / 53
Calling functions
R makes extensive use of functions†
Functions can be defined to takezero or more arguments
Functions typically return a valuea return value is not required
Functions are called by name withany arguments enclosed inparentheses
even if the function has noarguments the parentheses arerequired
sin(pi/2)
## [1] 1
print("Hello, world")
## [1] "Hello, world"
abs(-8)
## [1] 8
cos(2*sqrt(2))
## [1] -0.95136313
date()
## [1] "Sun Aug 31 17:08:42 2014"†http://en.wikipedia.org/wiki/Functional_programming
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 21 / 53
Assigning values to variables
Like other programming languages,values can be stored in variables
Variables are typically assignedin 1 of 3 ways:
assignment operator: <-
assignment function: assignequal sign: =
must be used to assignarguments in a function call
y <- 5y
## [1] 5
assign("e",2.7183)e
## [1] 2.7183
s = sqrt(2)s
## [1] 1.4142136
r <- rnorm(n=2)r
## [1] -1.0067110533 -0.0020828847
s*e+y
## [1] 8.8442567
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 22 / 53
Object orientation in R
Everything in R is an Object†
Use functions ls and objects to list all objects in the currentworkspace
x <- c(3.1416,2.7183)m <- matrix(rnorm(9),nrow=3)tab <- data.frame(store=c("downtown","eastside","airport"),sales=c(32,17,24))cities <- c("Seattle","Portland","San Francisco")ls()
## [1] "cities" "e" "filename" "m" "r" "s"## [7] "tab" "x" "y"
†http://en.wikipedia.org/wiki/Object-oriented_programmingGuy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 23 / 53
Object classes
All R objects have a class
The class of an object determineswhat it can do and what you cando with it
Use function class todisplay an object’s class
There are many R classes;basic classes are:
numericcharacterdata.framematrix
m
## [,1] [,2] [,3]## [1,] 0.374352397 0.586864810 -0.73778598## [2,] -0.071532765 -0.262264339 -0.19904931## [3,] 0.790144078 0.012603635 1.96472235
class(m)
## [1] "matrix"
tab
## store sales## 1 downtown 32## 2 eastside 17## 3 airport 24
class(tab)
## [1] "data.frame"
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 24 / 53
VectorsR is a vector/matrix programming language (also know as an arrayprogramming language†)
vectors can easily be created with c, the combine functionmost places where single value can be supplied, a vector can besupplied and R will perform a vectorized operation
my.vector <- c(2, 4, 3, 7, 10)my.vector
## [1] 2 4 3 7 10
my.vector^2
## [1] 4 16 9 49 100
sqrt(my.vector)
## [1] 1.4142136 2.0000000 1.7320508 2.6457513 3.1622777
†http://en.wikipedia.org/wiki/Array_programmingGuy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 25 / 53
Creating vectors with the c function
constants <- c(3.1416,2.7183,1.4142,1.6180)constants
## [1] 3.1416 2.7183 1.4142 1.6180
my.labels <- c("pi","euler","sqrt2","golden")my.labels
## [1] "pi" "euler" "sqrt2" "golden"
names(constants) <- my.labelsconstants
## pi euler sqrt2 golden## 3.1416 2.7183 1.4142 1.6180
The [1] in the above output is labeling the first element of the vectorThe c function can be used to create character vectors, numericvectors, as well as other types of vectors
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 26 / 53
Indexing vectors
Vectors indices are placed withsquare brackets: []
Vectors can be indexed in any of thefollowing ways:
vector of positive integersvector of negative integersvector of named itemslogical vector
constants[c(1,3,4)]
## pi sqrt2 golden## 3.1416 1.4142 1.6180
constants[c(-1,-2)]
## sqrt2 golden## 1.4142 1.6180
constants[c("pi","golden")]
## pi golden## 3.1416 1.6180
constants > 2
## pi euler sqrt2 golden## TRUE TRUE FALSE FALSE
constants[constants > 2]
## pi euler## 3.1416 2.7183
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 27 / 53
Creating integer sequences with the a:b operatorThe sequence operator will generate a vector of integers between a and bSequences of this type are particularly useful for indexing vectors, matrices,data.frames etc.1:5
## [1] 1 2 3 4 5
-(1:4)
## [1] -1 -2 -3 -4
letters[1:15]
## [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o"
letters[16:26]
## [1] "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"
letters[-(1:15)]
## [1] "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 28 / 53
Comparing vector and non-vector computing
# vectorized operation# taking the log of each element in a vectorx <- c(97.87,96.18,95,86.39,88.18,90.8,86.06,82.27,83.32,85.3,83.25,82.13,78.54)log(x)
## [1] 4.5836401 4.5662214 4.5538769 4.4588719 4.4793802 4.5086593 4.4550447## [8] 4.4100065 4.4226886 4.4461745 4.4218481 4.4083034 4.3636080
# non-vectorized computation# taking the log of each element in a vectorn <- length(x)y <- rep(0,n)for( i in 1:n )
y[i] <- log(x[i])y
## [1] 4.5836401 4.5662214 4.5538769 4.4588719 4.4793802 4.5086593 4.4550447## [8] 4.4100065 4.4226886 4.4461745 4.4218481 4.4083034 4.3636080
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 29 / 53
Comparing vector and non-vector computing
# vectorized operation# taking the log of each element in a matrixx <- matrix(c(2,9,4,7,5,3,6,1,8),nrow=3)x^2
## [,1] [,2] [,3]## [1,] 4 49 36## [2,] 81 25 1## [3,] 16 9 64
# non-vectorized computation# taking the log of each element in a matrixy <- xfor( i in 1:nrow(x) )
for( j in 1:ncol(x) )y[i,j] <- x[i,j]^2
y
## [,1] [,2] [,3]## [1,] 4 49 36## [2,] 81 25 1## [3,] 16 9 64
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 30 / 53
Outline
1 R language overview and history
2 R language references
3 Short R Tutorial
4 The R help system
5 Web resources for R
6 IDE editors for R
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 31 / 53
The HTML help system
R has a comprehensive Html helpfacility
Run the help.start functionR GUI menu itemHelp|Html help
help.start()
## If nothing happens, you should open## 'http://127.0.0.1:28913/doc/html/index.html' yourself
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 32 / 53
The help function
Obtain help on a particular topic viathe help function
help(topic)
?topic
help(read.table)
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 33 / 53
The help.search function
Search help for a particular topic viathe help.search function
help.search(topic)
??topic
??predict
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 34 / 53
Help tab in RStudio
RStudio incorporates a dedicated help tab which facilitates accessing the RHtml help system
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 35 / 53
Outline
1 R language overview and history
2 R language references
3 Short R Tutorial
4 The R help system
5 Web resources for R
6 IDE editors for R
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 36 / 53
R Homepage
http://www.r-project.org
List of CRAN mirror sitesManualsFAQsSite seachMailing listsLinks
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 37 / 53
CRAN - Comprehensive R Archive Network
http://cran.fhcrc.org
CRAN MirrorsAbout 45 countriesAbout 100 sites worldwideAbout 15 sites in US
R BinariesR Packages
5800+ packagesR SourcesTask Views
use your closest CRAN mirror siteGuy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 38 / 53
CRAN Task Views
Organizes the 5800+ R packages byapplication
FinanceTime SeriesEconometricsOptimizationMachine Learning
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 39 / 53
Stackoverflow
Stackoverflow has become the primary resource for help with R
http://stackoverflow.com/
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 40 / 53
R-SIG-FINANCE
Nerve center of the R financecommunity
Daily must read
Exclusively for Finance-specificquestions, not general Rquestions
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 41 / 53
Google’s R Style Guide
Naming conventionCoding SyntaxProgram Organization
http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 42 / 53
Quick R
http://www.statmethods.net
Introductory R LessonsR InterfaceData InputData ManagementBasic StatisticsAdvanced StatisticsBasic GraphsAdvanced Graphs
Site maintained by Robert Kabacoff, author of R in ActionGuy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 43 / 53
R graphics details, colors, and other tech notes
Site of Earl Glynn of Stowers Institute for Medical Research
R Graphics and other useful informationR Color ChartUsing Color in R (great presentation)Plot area, margins, multiple figuresMixture modelsDistance measures and clusteringUsing Windows Explorer to Start R with Specified Working Directory(under tech notes)
http://research.stowers-institute.org/efg/R/index.htm
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 44 / 53
Programming in R
Online R programming manual from UC Riverside:R Basics
Finding Help
Code Editors for R
Control Structures
Functions
Object Oriented Programming
Building R Packages
http://manuals.bioinformatics.ucr.edu/home/programming-in-r
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 45 / 53
Other useful R sites
R Bloggers Aggregation of about 550 R blogshttp://www.r-bloggers.com
R Site Search Search R function help, vignettes, R-helphttp://finzi.psych.upenn.edu/search.html
R Seek R specific search sitehttp://www.rseek.org/
Revolution Blog Blog from David Smith of Revolutionhttp://blog.revolutionanalytics.com
Inside-R R community site by Revolution Analyticshttp://www.inside-r.org
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 46 / 53
Outline
1 R language overview and history
2 R language references
3 Short R Tutorial
4 The R help system
5 Web resources for R
6 IDE editors for R
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 47 / 53
RStudio
RStudio is a fully-featured open-source IDEfor R
R language highlightingPaste/Source to R consoleobject explorertabbed graphics windowintegrated version control1-click kintr/Sweave compilation
RStudio also provides a server-based version (R running in the cloud)
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 48 / 53
Revolution R Enterprize Visual Development Environment
Revolution Analytics is a companythat sells a commercial distributionof R including a desktop IDE
Revolution R Enterprize is free toacademic users
R language highlightingPaste/Source code to RSource code debuggerobject explorerruns R in SDI mode
http://www.revolutionanalytics.com
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 49 / 53
WinEdt and R-Sweave
Based on WinEdt, an excellentshareware editor with support forLATEX and Sweave development
R language highlightingPaste/Source code to R1-click Sweave compilationSupports R in MDI modePaste/Source code to S-PLUS
http://www.winedt.comhttp://www.winedt.org/Config/modes/R-Sweave.php
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 50 / 53
StatET - An Eclipse Plug-In for R
StatET is a plug-in for theopen-source Eclipse developmentenvironment
R language highlightingPaste/Source code to RSource code debugger1-click Sweave compilationSupports R in SDI modeExcellent documentation byLonghow Lam
http://www.walware.de/goto/statet
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 51 / 53
Notepad++ and NpptoR
NpptoR is an automation widget(based on AuotHotkey) which allowsthe very useful program editorNotepad++ to interact with R
R language highlightingPaste/Source code to RSupports R in SDI mode
http://notepad-plus-plus.orghttp://sourceforge.net/projects/npptor
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 52 / 53
Computational Finance and Risk Management
http://depts.washington.edu/compfin
Guy Yollin (Copyright © 2014) R Programming for Quantitative Finance R Basics 53 / 53