This is a "let's try another way" post that is related to this one:
Is it possible to define/modify a reading function that
can handle the fact that data stored in an
xlsx
file is row-based (i.e. each row represents a variable)and transforms it accordingly so it can be stored in a column-based
data.frame
(i.e. what used to be a row inxlsx
becomes a column)while capturing the underlying class/data type of the row-based variables?
Regarding csv
files I would probably start with turning to readLines
, but unfortunately xlsx
is still a black box to me.
Here's a little xlsx
file that features examples for both data orientations: https://github.com/rappster/stackoverflow/blob/master/excel/row-and-column-based-data.xlsx
What about slightly modifying the
read.xlsx
function from thexlsx
package:or use stringsAsFactors=F if you prefer character data type: