Dear all,
I have a follow-on question to the discussion below. I am doing something
similar to the actions described in the email below however, all of the
file names that I wish to import begin with a number. S doesn't like this
so, I have used an awk script to change the file name to have an antecedent
letter eg. x, before I import the file. However, if I could somehow
change the file name during the import, it would be helpful because when I
talk about awk scripting to my users they get the "heebie jeebies". I use
version 6 on a Sun machine and 2000 on a wintel box. Any help would be
greatly appreciated.
TIA,
Chris
David C. Leeth
U.S. Geological Survey (WRD)
Atlanta, GA
Sundar Dorai-Raj
<sundar.dorai-raj@pdf.com To: James Dartnall
<J.E.DARTNALL@soton.ac.uk>
> cc:
s-news@lists.biostat.wustl.edu
Sent by: Subject: Re: [S]
Question: Naming dataframes
s-news-owner@lists.biosta
t.wustl.edu
02/10/2003 11:42 AM
James,
James Dartnall wrote:
> Hello, I have a query.
> I have a program to import a lot of data from excel (I have a lot (88)
excel
> files in a directory which I am importing into s-plus one excel file for
> each dataframe). My query is in the naming of the files. I want each
> dataframe to have exactly the same name as the excel file it was imported
> from but without the ".xls" on the end, how do I do this (simply)? At
the
> moment the program is written so that each dataframe name has the ".xls"
on
> the end as indicated in the second line of the for-loop.
>
> Accident <- files.in.dir("c:\\Accidents\\Cleaned")
> for(i in 1:88)
> {
> excelfile <- paste("c:\\Accidents\\Cleaned\\", Accident[i], sep="")
> dframe <- paste(Accident[i])
> import.data(DataFrame = dframe, FileName = excelfile,
FileType="excel")
> }
>
Use `substring' to chop off the last four characters (`.xls'):
dfframe <- substring(Accident[i], 1, nchar(Accident[i]) - 4)
Sundar
--------------------------------------------------------------------
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
|