s-news
[Top] [All Lists]

Re: object naming

To: ming hsu <hsu@charter.net>
Subject: Re: object naming
From: Spencer Graves <spencer.graves@PDF.COM>
Date: Mon, 31 Mar 2003 06:39:53 -0800
Cc: s-news@lists.biostat.wustl.edu
References: <web-1541583@rems01.cluster1.charter.net>
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01
Have you considered importing in a loop, something like the following:

        for(i in 1:length(files)){
                 df.i <- read.table(files[i])
                 print(summary(df.i))
        }

To make this work, you need to know that read.table works fine on all "files". I would do it in two steps, reading "files" into objects whose names are stored in a character vector "dfs". Then I'd try something like the following:

        for(i in 1:length(dfs))
            print(summary(get(dfs[i])))

Hope this helps.
Spencer Graves

ming hsu wrote:
Hi, this is kind of a silly syntax question, but I wasn't able to find the answer in the manual. I have a series of linear models that I wish to creat a summary table for. I tried to loop over the names with the following command

for ( i in 1:Length(files) )
    summary(files[i])

The problem is that SPlus takes files[i] as a string literal instead of a file name. How do I get around that?

Sincerely,
Ming Hsu
--------------------------------------------------------------------
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



<Prev in Thread] Current Thread [Next in Thread>