50 likes | 145 Views
Programming in R. Harry R Erwin, PhD CIS308 Faculty of Applied Sciences University of Sunderland. Resources. The Website has links to three programming tutorials. http://zoonek2.free.fr/UNIX/48_R/02.html is accessible.
E N D
Programming in R Harry R Erwin, PhD CIS308 Faculty of Applied Sciences University of Sunderland
Resources • The Website has links to three programming tutorials. • http://zoonek2.free.fr/UNIX/48_R/02.html is accessible. • http://cran.r-project.org/doc/manuals/R-intro.html provides examples to work through. • Lumley’s course http://faculty.washington.edu/tlumley/Rcourse/ is also good. • Work through the tutorial you find easiest.
What is R? • Statisticians use R to analyze data stored in objects that look like spreadsheets—data frames. You can think of R as spreadsheet scripting on steroids. • R is a functional language like Lisp, Python, or OCaML. (See http://en.wikipedia.org/wiki/Functional_programming.) • Specifically, functions in functional languages lack side-effects. • Eternal Flame by Bob Kanefsky and sung by Julia Ecklar (about Lisp, another functional language):
Learning R • Start R • We will work through some examples of R code from chapters 1 and 6 and Appendix E of Verzani’sUsing R for Introductory Statistics. • Afterwards, we’ll dip into the Zoonek programming tutorial (the second one). It has a bit more depth.
Use a Notes File • Open a new document and type the following into it: • # Notes • mean(rnorm(10)) • # To execute a selection in Windows, select it and type ctrl-R. • # In Mac OS, do the same, but type cmd-return instead. • # To source the entire edit file, use ctrl-E or cmd-E. • # The Windows FAQ is here: http://cran.r-project.org/bin/windows/base/rw-FAQ.html • Try ctrl-R on the contents and look at your command window. • I will now demonstrate a number of features of R. Take good notes!