Skip to content

Instantly share code, notes, and snippets.

@geofferyzh
Created April 16, 2012 18:14
Show Gist options
  • Save geofferyzh/2400454 to your computer and use it in GitHub Desktop.
Save geofferyzh/2400454 to your computer and use it in GitHub Desktop.
RinAction - R Importing Data - Excel
#################################################
# Import data from Excel #
#################################################
# the best way to read an Excel file is to export it to a comma-delimted file from
# within Excel and import it to R using the method described earlier
# RODBC on Windows
install.packages("RODBC")
library(RODBC)
channel <- odbcConnectExcel("C:/RinAction/data/data.xls")
mydataframe <- sqlFetch(channel,"data")
odbcClose(channel)
# Reading XLSX file
install.packages("xlsx")
library(xlsx)
workbook <- "C:/RinAction/data/data.xlsx"
mydataframe <- read.xlsx(workbook,"data")
mydataframe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment