|
Loading Data from an Excel file
Excel is not the most ideal format for importing into R. Merged cells, sheet formatting, embedded plots, etc can generally be a hassle. It is generally recommended to save the Excel file as a CSV prior to importing into R. However if this is not feasible, there are packages that can be loaded that will allow for Excel import. The example below shows how the XLConnect package can be used to import a .xls file.
install.packages("XLConnect") library (XLConnect) WorkingData = readWorksheetFromFile("Pathway_to_xls_file",sheet = #) or install.packages("XLConnect") library (XLConnect) WorkingData = readWorksheetFromFile("Pathway_to_xls_file",sheet = "SheetName") EXAMPLE: >install.packages("XLConnect") >library(XLConnect) > WorkingData = readWorksheetFromFile("C:/My Documents/SampleData.xls", sheet = 1) or >install.packages("XLConnect") >library(XLConnect) > WorkingData = readWorksheetFromFile("C:/My Documents/SampleData.xls", sheet = "TestSheet") IMPORTANT NOTES:
|