Lettura dei fogli

Introduzione all'importazione dei dati in R

Filip Schouwenaars

Instructor, DataCamp

Schermata 31-07-2019 alle 22.03.48.png

Introduzione all'importazione dei dati in R

XLConnect

  • Martin Studer

  • Lavora con Excel tramite R

  • Ponte tra Excel e R

  • XLS e XLSX

  • Funzionalità facile da usare

Introduzione all'importazione dei dati in R

Installazione

install.packages("XLConnect")
also installing the dependencies 'XLConnectJars', 'rJava'
...
  • Problemi?
    • Installa il Java Development Kit (JDK) di Oracle
    • Cerca l'errore su Google!
Introduzione all'importazione dei dati in R

loadWorkbook()

library("XLConnect")

book <- loadWorkbook("cities.xlsx")
str(book)
Formal class 'workbook' [package "XLConnect"] with 2 slots
  ..@ filename: chr "cities.xlsx"
  ..@ jobj    : ...
Introduzione all'importazione dei dati in R

getSheets()

getSheets(book)

"year_1990" "year_2000"

library(readxl)
excel_sheets("cities.xlsx")
"year_1990" "year_2000"
Introduzione all'importazione dei dati in R

readWorksheet()

readWorksheet(book, sheet = "year_2000")

    Capital Population
1  New York   17800000
2    Berlin    3382169
3    Madrid    2938723
4 Stockholm    1942362
Introduzione all'importazione dei dati in R

readWorksheet()

Schermata 31-07-2019 alle 22.13.15.png

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

     Col1
1 3382169
2 2938723
Introduzione all'importazione dei dati in R

Andiamo a praticare!

Introduzione all'importazione dei dati in R

Preparing Video For Download...