Agenda


Read data from

  • xls
  • xlsx
  • SAS
  • SPSS
  • STATA

Libraries


library(readxl)
library(haven)

Overview


  • list sheets in an excel file
  • read data from an excel sheet
  • read specific cells
  • read specific rows
  • read specific columns

List Sheets


excel_sheets('sample.xls')
## [1] "ecom"

Read Sheet


read_excel('sample.xls', sheet = 1)
## # A tibble: 7 x 5
##   channel        users new_users sessions bounce_rate
##   <chr>          <dbl>     <dbl>    <dbl> <chr>      
## 1 Organic Search 43296     40238    50810 48.72%     
## 2 Direct         12916     12311    16419 49.27%     
## 3 Referral       10983      7636    18105 22.26%     
## 4 Social         10346     10029    11101 61.92%     
## 5 Display         5564      4790     7220 83.30%     
## 6 Paid Search     2687      2205     3438 38.02%     
## 7 Affiliates      1773      1585     2167 55.75%

Read Specific Cells