Lecture des feuilles

Introduction à l’importation de données dans R

Filip Schouwenaars

Instructor, DataCamp

Capture d’écran du 31-07-2019 à 22.03.48.png

Introduction à l’importation de données dans R

XLConnect

  • Martin Studer

  • Travailler avec Excel via R

  • Faire le lien entre Excel et R

  • XLS et XLSX

  • Fonctions faciles à utiliser

Introduction à l’importation de données dans R

Installation

install.packages("XLConnect")
also installing the dependencies 'XLConnectJars', 'rJava'
...
  • Problèmes ?
    • Installez le Java Development Kit (JDK) d’Oracle
    • Cherchez votre erreur sur Google !
Introduction à l’importation de données dans R

loadWorkbook()

library("XLConnect")

book <- loadWorkbook("cities.xlsx")
str(book)
Formal class 'workbook' [package "XLConnect"] with 2 slots
  ..@ filename: chr "cities.xlsx"
  ..@ jobj    : ...
Introduction à l’importation de données dans R

getSheets()

getSheets(book)

"year_1990" "year_2000"

library(readxl)
excel_sheets("cities.xlsx")
"year_1990" "year_2000"
Introduction à l’importation de données dans R

readWorksheet()

readWorksheet(book, sheet = "year_2000")

    Capital Population
1  New York   17800000
2    Berlin    3382169
3    Madrid    2938723
4 Stockholm    1942362
Introduction à l’importation de données dans R

readWorksheet()

Capture d’écran du 31-07-2019 à 22.13.15.png

readWorksheet(book, sheet = "year_2000",                 
              startRow = 3, 
              endRow = 4,                 
              startCol = 2, 
              header = FALSE)

     Col1
1 3382169
2 2938723
Introduction à l’importation de données dans R

Passons à la pratique !

Introduction à l’importation de données dans R

Preparing Video For Download...