Synopsis: R is the most widely used software for statistical calculations. This explains how to get started with using R.
R Software
If you are starting wit R, you need to install
- The R software (http://www.r-project.org/)
- Optional, but recommended, an editor.
- For beginners, we strongly recommend RStudio (https://www.rstudio.com/)
- An alternative, specially if you’re familiar with eclipse, is the statET plugin for eclipse (http://www.walware.de/goto/statet)
Both is available for free on all major platforms.
R Tutorials for beginners
The following links are tutorials on using R as a language. They are helpful if you understand which statistical tests or analyses you want to do, and you just want to learn how to do it in R. They do typically NOT replace a proper statistics book that explains to you in detail why we do a regression, and whhat the assumptions are. If this is what you want to know, go to our stats section.
Recommended free tutorials
- Essential statistics lecture notes
- R for Beginners, by Emmanuel Paradis.
Other shorter intros
- A (very) short introduction to R, by Paul Torfs & Claudia Brauer, very compact
- An R reference card, by Matt Baggott
- An introduction to R, by Longhow Lam. Longer and more comprehensive than the other tutorials linked here.
Videos and MOOCs
- The IQUIT R video series highly recommended
- Coursera Data specialization
- Datacamp free intro R
- Coursera Data Analysis and Statistical Inference
- Udemy R basics
Websites with examples
- Quick-R (Highly recommend for beginners, have a look if your problem is here)
- R Examples Repository If you don’t find the test you need in Quick-R, have a look here
- Cookbook for R Similar to Quick-R
- R by example A lot of examples
Introductions in German
- Dormann, C. F. (2013) Parametrische Statistik. Springer, , 333-334. Free ebook for students from the University of Freiburg here (works only within the university network). Buy a paper version here
- Programmieren mit R
Finding a function in R
- The easiest way is to use the question mark: ?FUN to find the function FUN.
- If you don’t know the name, you can use: ??TOPIC to find functions where TOPIC features somewhere in the help page.
- Using package “SOS” and the tripple-question mark does a websearch (on R-help search) and returns the results: ???TOPIC. In contrast to ? and ?? it searches everythink, not only the installed pacakges.
- You may want to install Rdym (and load it) to automatically get suggestions in case you mistype a function name (see here for an example). “Is that what you mean?” (Cool!)
Getting started with Rstudio
- See also Appendix 1 of the Essential statistics lecture notes
File->New File->R Script to open a new R script
We can add comments with the symbol #
, to difference them from the codes
Use of run (top right) to run your script in the R consol (shortcut: Ctrl + enter)
While using RStudio, the working space is divided into 4 windows:
1) At the top righ window it is stored the work in the workspace memory.
we can also check ir by using the ls
command
ls()
## character(0)
2) At the top left we can write our script and save it for future uses.
3) Down left is the console where you can type commands and see output.
4) Down right is located the files tab, it shows all the files and folders in your default workspace. The plots tab will show all your graphs. The packages tab will list a series of packages or add-ons needed to run certain processes. For additional info see the help tab.
Some basic arithmetic functions
2+2
## [1] 4
2^2
## [1] 4
sqrt(2)
## [1] 1.414214
x = 2
log(x)
## [1] 0.6931472
log2(x)
## [1] 1
f = -34
abs(f)
## [1] 34