read.xls.html 3.16 KB
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>R: Read Excel files</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../R.css">
</head><body>

<table width="100%" summary="page for read.xls {gdata}"><tr><td>read.xls {gdata}</td><td align="right">R Documentation</td></tr></table>
<h2>Read Excel files</h2>


<h3>Description</h3>

<p>
Reads a Microsoft Excel file into a data frame
</p>


<h3>Usage</h3>

<pre>
read.xls(xls, sheet=1, verbose=FALSE, ..., perl="perl")
</pre>


<h3>Arguments</h3>

<table summary="R argblock">
<tr valign="top"><td><code>xls</code></td>
<td>
name of the Microsoft Excel file</td></tr>
<tr valign="top"><td><code>sheet</code></td>
<td>
number of sheet within the Excel file from which data are
to be read</td></tr>
<tr valign="top"><td><code>verbose</code></td>
<td>
logical flag indicating whether details should be
printed as the file is processed.</td></tr>
<tr valign="top"><td><code>perl</code></td>
<td>
name of the perl executable to be called.</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
additional arguments to read.table. The defaults of
read.csv are used.</td></tr>
</table>

<h3>Details</h3>

<p>
This function works translating the named Microsoft Excel file into a
temporary .csv file, using Greg Warnes' xls2csv Perl script (installed
as part of the gregmisc package).
</p>
<p>
Caution: In the conversion to csv, strings will be quoted. This can be
problem if you are trying to use the <code>comment.char</code> option of
<code>read.table</code> since the first character of all lines (including
comment lines) will be """ after conversion.
</p>


<h3>Value</h3>

<p>
a data frame</p>

<h3>Note</h3>

<p>
Either a working version of Perl must be present in the executable
search path, or the exact path of the perl executable must be provided
via the <code>perl</code> argument.  See the examples below for an illustration.
</p>


<h3>Author(s)</h3>

<p>
Jim Rogers <a href="mailto:james.a.rogers@pfizer.com">james.a.rogers@pfizer.com</a>, modified
and extended by Gregory R. Warnes <a href="mailto:warnes@bst.rochester.edu">warnes@bst.rochester.edu</a>.
</p>


<h3>References</h3>

<p>
http://www.analytics.washington.edu/statcomp/downloads/xls2csv
</p>


<h3>See Also</h3>

<p>
<code><a href="../../base/html/read.csv.html">read.csv</a></code>
</p>


<h3>Examples</h3>

<pre>

   # iris.xls is included in the gregmisc package for use as an example
   xlsfile &lt;- file.path(.path.package('gdata'),'xls','iris.xls')
   xlsfile

   iris &lt;- read.xls(xlsfile)
   head(iris)  # look at the top few rows

  ## Not run: 
   # Example specifying exact Perl path for default MS-Windows install of
   # ActiveState perl
   iris &lt;- read.xls(xlsfile, perl="C:\perl\bin\perl.exe")

   # Example specifying exact Perl path for Unix systems
   iris &lt;- read.xls(xlsfile, perl="/usr/bin/perl")
   ## End(Not run)
</pre>



<hr><div align="center">[Package <em>gdata</em> version 2.3.1 <a href="00Index.html">Index]</a></div>

</body></html>