Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chris Knight Beginners’ workshop.

Similar presentations


Presentation on theme: "Chris Knight Beginners’ workshop."— Presentation transcript:

1 Chris Knight Chris.knight@manchester.ac.uk Beginners’ workshop

2 What is R? Statistics package General modelling tool Data visualisation and analysis tool Programming language Glorified pocket calculator “Environment for statistical computing and graphics” http://r4stats.com/articles/popularity/

3 Why use R? Lots of help available Free Big user base Increasingly used for doing science Jobs! Cutting edge and growing functionality If you learn only one new piece of computing software after Excel, learn R

4 What’s in this workshop Basic interaction with R Where to turn for help Moving rapidly to more complex analyses Where to learn more

5 What’s not in this workshop Advanced programming See e.g. ?Control, ?"function" and resources (later) ‘How do I analyse X?’ Google (e.g. ‘time series R’) and resources (later) The fundamentals of statistics See resources given later, esp. Crawley books Working in R environments other than Rstudio (www.rstudio.com) Default Windows GUIDefault Mac GUI R commander Command line

6

7 R as a calculator > 9+2-1 [1] 10 > 5*0.5 [1] 2.5 > 27/3 [1] 9 > 9^2 [1] 81 > 9^(1/2) [1] 3 > sqrt(9) [1] 3 > log(5) [1] 1.609438

8 R help documentation > log(5) [1] 1.609438 Check what the log() function is doing (e.g. which base?) > ?log General information Package Arguments and defaults What those arguments need to be What’s covered

9 > log(5) [1] 1.609438 Check what the log() function is doing (e.g. which base?) > ?log If you really care Where it’s come from Sometimes very useful, sometimes not Run from here or use example(log) What you get back Useful link R help documentation

10 > log(5) [1] 1.609438 Check what the log() function is doing (e.g. which base?) > ?log

11 R as a calculator > log(5) [1] 1.609438 Check what the log() function is doing (e.g. which base?) > ?log > log(5, base=10) [1] 0.69897 > log10(5) [1] 0.69897 What happens if you get it wrong? > log("Fred") Error in log(“Fred") : non-numeric argument to mathematical function > log function (x, base = exp(1)).Primitive("log") So if natural log isn’t ln(5), what is ln used for? > ?ln

12 R as a calculator Comparisons > 54 > 45 Greater than [1] TRUE > 2 < 1 Less than [1] FALSE > 15 == 15 Exactly equal [1] TRUE > 50 >= 50 Greater than or equal [1] TRUE > 5 > 1 & 9 <= 15 Are both statements true? [1] TRUE > 24 == 3 | 1 == 1 Is either statement true? [1] TRUE > ?Comparison > ?Syntax

13 Keeping track of what you’re doing Store code in a text file (.R) Write in comments #like this Run commands a line at a time Ctl R (Windows) ⌘↵ (Mac) Highlight code and run in the same way Run a whole file using the source() function Navigate history using arrows

14 Keeping track of what you’re doing Try running the first 32 lines one at a time or in one go url.show(“http://personalpages.manchester.ac.uk/staff/Chri s.Knight/docs/RbeginnersWorkshop14.R”) Try saving the file somewhere useful Try writing some more commented and uncommented lines Use R as a web browser to see the file containing this workshop’s code: Copy it to a new R script file (.R)

15 Further sections Assign values to a variable<- Create vectorsc() Simple statistics Extracting bits of variables [] loopfor (var in seq){} Data framesread.table(); write.table(); [,] Simple plotsplot(y~x); pairs(), hist() Build linear modelslm(y~x); anova() Modelling exerciserpart(y~x); randomForest(y~x)

16 Statistics Crawley Books Courses Masters’ lectures now! https://www.coursera.org/course/statistics Places to go for more information http://cran.r-project.org/web/views/ Task views Specific books Many online with UoM access e.g. 43 in UseR! series: http://link.springer.com/bookseries/6991 Data manipulation with R by Phil Spector very broadly useful R programming R site documents (start with ‘Documents with fewer than 100 pages’) http://cran.r-project.org/other-docs.html Courses https://www.coursera.org/course/compdata

17 Places to go for help R help list archives http://www.r-project.org/ > Mailing lists > R-help web interface > Searchable archives R help documentation ? ?? help(package="base") demo() example("function") vignette() R support groups FLS (FLSRGROUP listerv) or email marco.smolla@postgrad.manchester.ac.uk Manchester R User group http://www.meetup.com/Manchester-R/ Google


Download ppt "Chris Knight Beginners’ workshop."

Similar presentations


Ads by Google