Introduction to R


TP 1

Prof. Patrick Meyer

BioSys Lab - Université de Liège

Assignations

  1. a) 6 6 6
    b) 3 2 2
    c) 6 6 6

    Watch explanation:


    d) 6 2 2
    e) -4 -4 1
    f) 16 6 1

    Watch explanation:

  2. save <- a
    a <- b
    b <- save
    

    Watch explanation:

Functions

  1. Euros to Belgian francs conversion:

  2. nextnextFibonacci computation:

    Watch explanation:

  3. bmi <- function(weight,height) {
    weight/(height*height)
    }
    

    Watch explanation:

  4. far2cel <- function(far) {
    (far-32)*(5/9)
    }
    

    Watch explanation:

  5. distance <- function(x1,y1,x2,y2) {
    sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
    }
    

    Watch explanation:

Vectors

  1. bmi

    Watch explanation:

  2. Boolean logic

    Watch explanation:

  3. Sub-vector selection

    Watch explanation:

  4. DAT[POS]
    

    Watch explanation:

  5. scalprod <- function(u,v) {
    sum(u*v)
    }
    

    Watch explanation: