Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the xlsx package work for xlsm files in R?

Tags:

r

xlsx

xlsm

I am trying to read a range into a data.frame from a xlsm workbook. Can I do this with the xlsx package in R? If not, does anyone know of a way to do it?

Thank you!

like image 774
overflowname Avatar asked Jun 26 '12 20:06

overflowname


2 Answers

Did you try using read.xlsx or read.xlsx2 as described in the manual?

http://cran.r-project.org/web/packages/xlsx/xlsx.pdf

If these do not work with your file format, and you are trying to access tabular data you might want to open the .xlsm and export your data to csv format.

These are easily imported uisng read.csv('filename.csv')

like image 56
John Avatar answered Sep 22 '22 04:09

John


read.xlsx from R3.2 will read in data saved in an xlsm workbook, but you need the correct postfix and the file saved in the same directory (or full filename), e.g.

LotsofmydatainRdataframe <- read.xlsx(LotsofmydatainExcel.xlsm,sheetName="Deaths",as.data.frame=TRUE)

if you try just LotsofmydatainExcel or LotsofmydatainExcel.xlsx then file will not be found.

Annoyingly the following produces an unknown format xlsm error in R

write.xlsx(LotsofmydatainRdataframe, LotsofmydatainExcel.xlsm,sheetName="Output")
like image 21
hopethishelps Avatar answered Sep 25 '22 04:09

hopethishelps