[R] Import data from Excel to R

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Wed Sep 10 16:00:50 CEST 2014

Although it may seem troublesome to export to csv, I have found that every direct access library for reading Excel files seems to come with some fiddly bits that confuse new users (and can show down an experienced user). For example, XLConnect can be a headache if your files are large because it seems to use memory inefficiently and requires preallocation for loading the library for large files. It also requires a working Java installation with the right OS architecture which can be an off-topic diversion on this list. And of course there are the xlsx vs xls compatibility problems and the people who sprinkle data around the spreadsheet randomly that add steps to the data extraction that we can't predict.
Telling new users to start out by exporting to CSV is a compact way to get them to solve the their data transfer problem interactively. Most people working with xls/xlsx files have a spreadsheet program with which they can accomplish this initial task, and leave the fiddly bits until they decide to streamline their data processing.
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
Sent from my phone. Please excuse my brevity.

On September 10, 2014 5:45:49 AM PDT, John McKown <john.archie.mckown at gmail.com> wrote:
>On Wed, Sep 10, 2014 at 3:51 AM, Omar André Gonzáles Díaz
><oma.gonzales at gmail.com> wrote:
>> The best way is to save the file as CSV... after you can simply
>import it
>> with this comand in R:
>> read.csv(...) ... to know more about the read.csv comand use in R
>> ?read.csv.
>> There are other packages to import EXCEL FILES, but the simplest way,
>> importing this as CSV.
>I agree, if the person is using R on a Windows system. And they have
>Excel installed on it. If, like me, they are on a non-Windows system,
>then it _might_ be faster and easier to use a package from CRAN such
>as openxlsx (my favorite because it is native C code), or XLConnect
>(Java based, using the Apache foundarion's POI code). These could be
>used on Windows also. If the OP just wanted to run an R script without
>first needing to start up Excel, open the spreadsheet, save the data
>in CSV format, then run the R script. What can I say? I'm lazy! (And
>_proud_ of it).
>There is nothing more pleasant than traveling and meeting new people!
>Genghis Khan
>Maranatha! <><
>John McKown
>R-help at r-project.org mailing list
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list