Introduction to Importing Data in R
Filip Schouwenaars
Instructor, DataCamp
Martin Studer
Work with Excel through R
Bridge between Excel and R
XLS and XLSX
Easy-to-use functionality
install.packages("XLConnect")
also installing the dependencies 'XLConnectJars', 'rJava'
...
library("XLConnect")
book <- loadWorkbook("cities.xlsx")
str(book)
Formal class 'workbook' [package "XLConnect"] with 2 slots
..@ filename: chr "cities.xlsx"
..@ jobj : ...
getSheets(book)
"year_1990" "year_2000"
library(readxl)
excel_sheets("cities.xlsx")
"year_1990" "year_2000"
readWorksheet(book, sheet = "year_2000")
Capital Population
1 New York 17800000
2 Berlin 3382169
3 Madrid 2938723
4 Stockholm 1942362
readWorksheet(book, sheet = "year_2000",
startRow = 3,
endRow = 4,
startCol = 2,
header = FALSE)
Col1
1 3382169
2 2938723
Introduction to Importing Data in R