| To: | s-news@wubios.wustl.edu |
|---|---|
| Subject: | [S] Re: Products of pairs |
| From: | fear@scmp.scm.liverpool.ac.uk (Simon Fear) |
| Date: | Fri, 27 Mar 1998 19:01:35 GMT |
| Sender: | owner-s-news@wubios.wustl.edu |
> Is there a simple way to obtain the products of all possible pairs of
> values that are in a data frame column?
This recursive function will do it, not necessarily as quickly as some other
suggestions I'm sure you will get.
> cprods
function(x)
{
if(length(x) <= 1)
return(NULL)
else c(x[1] * x[-1], cprods(x[-1]))
}
Simon Fear
-----------------------------------------------------------------------
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> |
|---|---|---|
| ||
| Previous by Date: | Re: [S] Is this really good programming practice?, Jeffrey J. Hallman |
|---|---|
| Next by Date: | [S] SET S-NEWS NOMAIL, Fehd, Ronald J. |
| Previous by Thread: | [S] na.include, WayWay M. Hlaing |
| Next by Thread: | [S] SET S-NEWS NOMAIL, Fehd, Ronald J. |
| Indexes: | [Date] [Thread] [Top] [All Lists] |