Skip to content

Import data from Excel to R

8 messages · JAWADI Fredj, Ista Zahn, Peter Alspach +5 more

#
Hi
I am a New user of R.
Please, how to import data from Excel to R?
Thanks,
Best regards,
Fredj,
#
Read the manual.

http://cran.r-project.org/doc/manuals/r-release/R-data.html#Reading-Excel-spreadsheets

Best,
Ista
On Sep 9, 2014 6:39 PM, "JAWADI Fredj" <fredj.jawadi at france-bs.com> wrote:

            

  
  
#
Tena koe Fredj

There are lots of ways, depending on your precise task and preference.  Have you Googled 'Import data from Excel to R'?  That will bring up lots of relevant hits, including the data import/export manual that ships with R.

FWIW, I use RODBC and have written a simple wrapper to do the most standard tasks (which I can share if you like) ....

Peter Alspach

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of JAWADI Fredj
Sent: Wednesday, 10 September 2014 8:48 a.m.
To: r-help at R-project.org
Subject: [R] Import data from Excel to R

Hi
I am a New user of R.
Please, how to import data from Excel to R?
Thanks,
Best regards,
Fredj,



______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
The contents of this e-mail are confidential and may be ...{{dropped:14}}
#
On Tue, Sep 9, 2014 at 4:48 PM, JAWADI Fredj <fredj.jawadi at france-bs.com> wrote:
There are some ways listed here:
https://web.archive.org/web/20131109195709/http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows&s=excel
#
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 this:
?read.csv.

There are other packages to import EXCEL FILES, but the simplest way, its
importing this as CSV.

2014-09-09 18:03 GMT-05:00 Gabor Grothendieck <ggrothendieck at gmail.com>:

  
  
#
On Wed, Sep 10, 2014 at 3:51 AM, Omar Andr? Gonz?les D?az
<oma.gonzales at gmail.com> wrote:
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).
#
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:
#
Most of the time I would agree with csv being the best format.  _If_ you
are dealing with plain ASCII text.

Having spent most of yesterday with an Excel spreadsheet containing Russian
letters, I can say it is quite difficult to export the data to Unicode
UTF-16 tab-delimited text and then successfully import it to R.  At least
on Windows.  Maybe dependent upon the locale as well. (Google around on
this topic and you find some people seem to be able to succeed at this
task, but at least some other people have had problems.)

What did seem to work reliably for Unicode-containing spreadsheets was to
use the XLConnect package and read the xlsx file directly.

Kevin Wright


On Wed, Sep 10, 2014 at 3:51 AM, Omar Andr? Gonz?les D?az <
oma.gonzales at gmail.com> wrote: