s-news
[Top] [All Lists]

Re: [S] Changing a list to a vector

To: Don MacQueen <macqueen1@llnl.gov>, s-news <s-news@wubios.wustl.edu>
Subject: Re: [S] Changing a list to a vector
From: Patrick Burns <pburns@pburns.seanet.com>
Date: Thu, 21 May 1998 19:24:30 +0000
References: <199805191704.KAA28985@shell.portal.ca> <199805191704.KAA28985@shell.portal.ca> <v03102802b18a1c28edcd@[128.115.153.61]>
Reply-to: pburns@pburns.seanet.com
Sender: owner-s-news@wubios.wustl.edu

Don MacQueen wrote:

> Very instructive, and thank you for mentioning it. But I haven't finished
> learning yet...
>
> > foo <- list(z=1:4, b=9:7, x=runif(3))
> > do.call('c',foo)
>  z1 z2 z3 z4 b1 b2 b3        x1        x2      x3
>   1  2  3  4  9  8  7 0.5649553 0.4697681 0.48498
> > do.call('min',foo)
> [1] 0.4697681
> > do.call('max',foo)
> [1] 9
> > do.call('range',foo)
> [1] 0.4697681 9.0000000
> > do.call('mean',foo)
> Error in call to mean(): Argument z= not matched
> Error in call to mean(): Argument b= not matched
> Dumped
> > mean(unlist(foo))
> [1] 3.55197
> >

I presume that you are fishing for further explanation.
The "do.call" function takes a character string naming a function, and a
list.
The list is the set of arguments given to the function, and the names of the

list are the names of the arguments in the call to the function.  "S Poetry"

has a brief explanation of "do.call" along with some examples of it in real
life.

Pat Burns
pburns@pburns.seanet.com
http://www.seanet.com/~pburns/Spoetry


-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

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