- To import/export data into/from R:
- Install xlsx package: install.packages("xlsx")
- Turn on the library: library(xlsx)
- For example, there is excel workbook called 'mydata' and you want to upload a data from its worksheet called 'Data' : myfile = read.xlsx("mydata.xlsx", sheetName = "Data")
- To export data from R into excel, run: write.xlsx(mydata, "myfile.xlsx")
- Alternative package for handling Excel files:
install.packages("devtools")
devtools::install_github("kassambara/r2excel")
2. To turn on the package, run:
library(r2excel)
3. Import data from Excel file:
mydata=xlsx.readFile('/pathToExcelFile/mydata.xlsx', sheetIndex = 1, header = TRUE)
Reference