• assigning value: x<-1
  • vector (array with one dimension – integer numbers as index): x<-c(1,2,3,4,5)
  • list (array with one dimension – string index): x<-list(first=”something”, second=1111.34, “3”=”hi”)
    print looks like this:

    $first
    [1] "something"
    
    $second
    [1] 1111.34
    
    $`3`
    [1] "hi"
    
  • help for function: help(sum)
  • example for function: example(sum)
  • basic sum, with or without NA values: sum( …., rm.NA=FALSE/ TRUE )
  • loading of library (lattice is library for charts and graphics): library(lattice)
  • basic if statement: if (1>2) “bigger” else “smaller”
  • more commands on one line: “hello”; 1+2; sqrt(16)
  • several special values: NA (not available), Inf/ -Inf (infinity), NaN (not a number), NULL – all these values are different!
  • power, square: 10^2, sqrt(16)
  • user defined operator: `%myoperation%` <- function(x, y) {2*x+3*y}
    usage:

    > 1 %myoperation% 5
    [1] 17
    
  • user defined function:
    > f<-function(x) {x+x^2}
    > f(3)
    [1] 12
    
  • maximum, minimum (more then 2 values): max(….), min(….)