Re: [R] numeric operations w/ lists

From: Sean Davis <sdavis2_at_mail.nih.gov>
Date: Wed 10 Aug 2005 - 03:01:27 EST


On 8/9/05 12:21 PM, "Afshartous, David" <afshart@exchange.sba.miami.edu> wrote:

>
> Hello all,
>
> X is a list of 20 lists, and each individual list has 65 elements.
>
> Y is a list of 65 elements.
>
> WANT: subtract Y from each of the 20 lists in X.
>
> Here's what I tried and the error messages:
>
>> X - rep(Y, 20)

See ?lapply. Something like:

NewX <- lapply(X,function(tmp) {tmp-Y})

Hope this helps.

Sean



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Aug 10 03:06:51 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:11:39 EST