s-news
[Top] [All Lists]

Re: Processing a list

To: "Data Analytics Corp." <dataanalytics@earthlink.net>
Subject: Re: Processing a list
From: David L Lorenz <lorenz@usgs.gov>
Date: Mon, 24 Sep 2007 07:36:46 -0500
Cc: s-news@lists.biostat.wustl.edu, s-news-owner@lists.biostat.wustl.edu
In-reply-to: <46F549D6.20905@earthlink.net>

Walt,
  You need to pass the object to describe, not just the name. Try this

lapply(x, function(y) describe(get(y)))

Dave


"Data Analytics Corp." <dataanalytics@earthlink.net>
Sent by: s-news-owner@lists.biostat.wustl.edu

09/22/2007 11:59 AM

To
s-news@lists.biostat.wustl.edu
cc
Subject
[S] Processing a list





Hi,

I have 100 data frames for a project, each data frame beginning with the
word "data" followed by a word for the data itself.  I'd like to write a
function to loop through each data frame and apply the describe function
from the HMISC library.  I created a list using

       x <- as.list(objects(pattern = "data*"))

which returns a list with 100 elements, each of which is the data frame
name as a character.  Then I did

         lapply(x, describe)

and got garbage.  I think the issue is that x contains character strings
which a function cannot use as the name of an object.  How do I tell S+
to treat each character string in the list x as a data frame name which
could then be read by describe?

I'm using s+8.0 if that matters.

Thanks,

Walt Paczkowski
--------------------------------------------------------------------
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>