If you have S-PLUS 7.0 available, you could use the new colTypes argument to
importData. This will let you specify the column types in advance as
character, and convert them later as you suggest.
Otherwise, my only thought would be: are these .csv files or .xls files?
Many data collection systems create .csv files, which are just
comma-separated ASCII files. In this case you could use the lower-level
scan() function to read the data, and specify the types with the "what"
argument.
# David Smith
--
David M Smith <dsmith@insightful.com>
Senior Product Manager, Insightful Corp, Seattle WA
Tel: +1 (206) 802 2360
Fax: +1 (206) 283 6310
Insightful Corporation (www.insightful.com) provides analytical solutions for
text and data using S-PLUS, Insightful Miner, InFact and consulting services.
> -----Original Message-----
> From: John Kershaw [mailto:kershaw@unb.ca]
> Sent: Thursday, November 10, 2005 10:23 AM
> To: s-news@lists.biostat.wustl.edu
> Subject: [S] Importing Excel Worksheets with multiple formats
>
>
> Hello All,
>
> I have been trying to import a batch of excel files (about
> 800) in Splus
> 6.2 for Windows. The files are autocreated by a data
> collection system.
> I have figured out how to do this as a batch, but I have one
> complication.
> The first ten rows of each file contains Unit Descriptors
> with the heading
> in the first column and the value in the second column. I
> have figured
> out how to read the first 10 rows and transpose it into a
> data.frame with
> the first column becoming the names of the elements in the
> data.frame. My
> problem is that there is one variable somewhere in the middle of the
> rows that is text and the rest are numeric, so Splus assigns NA to the
> text value. Is there any way to force Splus to import
> everything as text?
> I can then use as.numeric to convert the values I need to be
> numeric. I
> really don't want to have to edit each excel file if possible.
>
> Any help, hints, or solutions are, as always, greatly appreciated.
>
> JAK
>
> --------------------------------------------------------------------
> This message was distributed by s-news@lists.biostat.wustl.edu. To
> unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
> the BODY of the message: unsubscribe s-news
>
|