s-news
[Top] [All Lists]

Re: creating a data frame from a vector of character strings

To: "Schwarz,Paul" <PSchwarz@gcrinsight.com>
Subject: Re: creating a data frame from a vector of character strings
From: Tim Hesterberg <timh@insightful.com>
Date: 7 Nov 2005 11:17:30 -0800
Cc: <s-news@lists.biostat.wustl.edu>
In-reply-to: <89C7DEAADB79564DB278694EB2417CCE56F164@CHOCOLATE.GCRInsight.com> (PSchwarz@gcrinsight.com)
References: <89C7DEAADB79564DB278694EB2417CCE56F164@CHOCOLATE.GCRInsight.com>
You could use a combination of
        paste()                         (to create a text string to evaluate)
        eval(parse(text="the command")) (to evaluate the string)
e.g. if your vector is c("a", "b") you want:

        eval(parse(text="data.frame(a,b)"))

Tim Hesterberg

>Hi S-News readers,
>
>I'm looking for a way to create a data frame using a vector of character
>strings returned by the objects() function. In other words, objects(pat=
>"xdata.*") returns a charcter vector of the names of objects, but I
>haven't figured out how to convert this character vector into the actual
>objects to pass to the data.frame() function. I know it seems straight
>forward but I haven't figured out how to do it.
>
>I'd appreciate help and suggestions.
>
>Thanks in advance.
>
>Paul Schwarz

========================================================
| Tim Hesterberg       Research Scientist              |
| timh@insightful.com  Insightful Corp.                |
| (206)802-2319        1700 Westlake Ave. N, Suite 500 |
| (206)283-8691 (fax)  Seattle, WA 98109-3012, U.S.A.  |
|                      www.insightful.com/Hesterberg   |
========================================================
Download the S+Resample library from www.insightful.com/downloads/libraries

Two Research Scientist positions:
        data mining
        frailty/mixed effects
    http://www.insightful.com/company/jobs.asp

Speak out about biased science in Washington D.C.
    http://home.comcast.net/~timhesterberg/ScientificIntegrity.html


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