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

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.

Other shorter intros

Videos and MOOCs

Websites with 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

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