User Tools

Site Tools


r

Table of Contents

CoursInformatique

Installation

R

sudo aptitude install r-base

RStudio

sudo aptitude install libjpeg62

Télécharger RStudio Desktop pour Debian sur http://www.rstudio.com/products/rstudio/download/

sudo dpkg -i rstudio-0.98.1062-i386.deb

Basics

Packages:

  • needs to be installed once
  • needs to be loaded each session
library(package)

Tips:

  • ctrl+return = run the selected code

Structures:

  • vectors
    • character
    • numeric
    • logic
  • matrices
    • combine vectors of same type and same length
  • data frames
    • no conditions on type and same length
  • lists
    • no conditions on type nor length

Things that can be done with R (seen at the flamescourse)

  • import datasets
  • create functions
  • tables (needed for charts)
  • plotting graphics
    • bar chart, pie chart
    • boxplots
    • qq-plots
  • descriptive statistics
    • categorical data
    • continuous data
      • central tendencies: mean, median, mode, min, max
      • variance
  • statistical inference
    • categorical data
      • chi², Fisher, binomial, prop.test
    • continous data
      • t-test (one and two sample), Wilcoxon, regression

Assign value = or <-, differences : in a function

  • = : local
  • <- : global ?

N.B. : the comparator is '=='

Notes

Pour faire ceci (avec SAS):

data example_zhsites;
  set example_zhsites;
  if f_no_ebeds=1 then nbeds_e2=5;
run;

en r, il faut passer par une boucle et assigner chaque item du vecteur ([i]) :

for(i in 1:nrow(example_zhsites)) {
  if (example_zhsites$f_no_ebeds[i] == 1) {
    example_zhsites$nbeds_e2[i] = 5
  }
}

source : The condition has length > 1 and only the first element will be used

r.txt · Last modified: 2017/02/01 11:40 by carl