Created
April 16, 2012 18:14
-
-
Save geofferyzh/2400454 to your computer and use it in GitHub Desktop.
RinAction - R Importing Data - Excel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################# | |
# 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