An Introduction to R - PowerPoint PPT Presentation

Jims
an introduction to r l.
Skip this Video
Loading SlideShow in 5 Seconds..
An Introduction to R PowerPoint Presentation
Download Presentation
An Introduction to R

play fullscreen
1 / 18
Download Presentation
An Introduction to R
327 Views
Download Presentation

An Introduction to R

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. An Introduction to R Free software for repeatable statistics, visualisation and modeling Dr Andy Pryke, The Data Mine Ltd Andy@AndyPryke.com Dr Andy Pryke - The Data Mine Ltd

  2. Outline 1. Overview What is R? When to use R? Wot no GUI? Help and Support 2. Examples Simple Commands Statistics Graphics Modeling and Mining SQL Database Interface 3. Going Forward Relevant Libraries Online Courses etc. Dr Andy Pryke - The Data Mine Ltd

  3. What is R? • Open source, well supported, command line driven, statistics package • 100s of extra “packages” available free • Large number of users - particularly in bio-informatics and social science • Good Design - John Chambers received the ACM 1998 Software System Award for “S” Dr. Chambers' work "will forever alter the way people analyze, visualize, and manipulate data…” Dr Andy Pryke - The Data Mine Ltd

  4. When Should I Use R? • To do a full cycle of: • data import • data pre-processing • exploratory statistics and graphics, • modeling and data mining • report production • integration into other systems. • Or any one of these steps - i.e. just to standardise pre-processing of data Dr Andy Pryke - The Data Mine Ltd

  5. Wot no GUI? or “The Advantages of Scripting” • Repeatable • Debug-able • Documentable • Build on previous work • Automation • Report generation • Website or system integration • Links from Perl, Python, Java, C, TCP/IP…. Dr Andy Pryke - The Data Mine Ltd

  6. Help and Support Built in help/example system (e.g. type “?plot”) Many tutorials available free R-Help mailing list • Archived online • Key R developers respond • Contributors understand statistical concepts Large User Community Dr Andy Pryke - The Data Mine Ltd

  7. Simple Commands 1+1 2 10*3 30 c(1,2,3) 1 2 3 c(1,2,3)*10 10 20 30 x <- 5 x*x 25 exp(1) 2.718282 q() Save workspace image? [y/n/c]:n Dr Andy Pryke - The Data Mine Ltd

  8. Simple Statistics colnames(iris) "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width” "Species" plot(iris$Sepal.Length, iris$Petal.Length) # Pearson Correlation cor(iris$Sepal.Length, iris$Petal.Length) 0.8717538 # Spearman Correlation cor(rank(iris$Sepal.Length), rank(iris$Petal.Length)) 0.8818981 Dr Andy Pryke - The Data Mine Ltd

  9. Graphics January Pie Sales Cherry Blueberry Apple Vanilla Cream Other Boston Cream Dr Andy Pryke - The Data Mine Ltd

  10. Linear Models ## Scatterplot of Sepal and Petal Length plot(iris$Sepal.Length, iris$Petal.Length) ## Make a Model of Petals in terms of Sepals irisModel <- lm(iris$Petal.Length ~ iris$Sepal.Length) ## plot the model as a line abline(irisModel)

  11. Classification Trees # Model Species irisct <- ctree(Species ~ . , data = iris) # Show the model tree plot(irisct) # Compare predictions table(predict(irisct), iris$Species) Dr Andy Pryke - The Data Mine Ltd

  12. SQL Interface Connect to databases with ODBC library("RODBC") channel <- odbcConnect("PostgreSQL30w", case="postgresql") sqlSave(channel,iris, tablename="iris") myIris <- sqlQuery(channel, "select * from iris") Dr Andy Pryke - The Data Mine Ltd

  13. Data Mining Libraries (i) RandomForest • Random forests - Robust prediction Party • Conditional inference trees - Statistically principled • Model-based partitioning - Advanced regression • cForests - Random Forests with ctrees e1071 • Naïve Bayes, Support Vector Machines, Fuzzy Clustering and more... Dr Andy Pryke - The Data Mine Ltd

  14. Data Mining Libraries (ii) nnets • Feed-forward Neural Networks • Multinomial Log-Linear Models BayesTree • Bayesian Additive Regression Trees gafit & rgenoud • Genetic Algorithm based optimisation varSelRF • Variable selection using random forests Dr Andy Pryke - The Data Mine Ltd

  15. Data Mining Libraries (iii) arules • Association Rules (links to ‘C’ code) Rweka library • Access to the many data mining algorithms found in open source package “Weka” dprep • Data pre-processing • You can easily write your own functions too. Bioconductor • Multiple packages for analysis of genomic (and biological) data Dr Andy Pryke - The Data Mine Ltd

  16. Sources of Further Information Download these slides + the examples & find links to online courses in R here: http://www.andypryke.com/pub/R Dr Andy Pryke - The Data Mine Ltd

  17. Dr Andy Pryke - The Data Mine Ltd

  18. Editors which Link to R • Rgui (not really a GUI) • Emacs (with “ESS” mode) • RCmdr • Tinn-R • jgr - Ja • SciViews • and more... Dr Andy Pryke - The Data Mine Ltd