s-news
[Top] [All Lists]

Re: [s-news] S-News Daily Digest V2 #1954

To: Doug Bolgiano <dougb@psbcresearch.org>
Subject: Re: [s-news] S-News Daily Digest V2 #1954
From: David L Lorenz <lorenz@usgs.gov>
Date: Fri, 16 Jan 2009 13:07:30 -0600
Cc: s-news@lists.biostat.wustl.edu, s-news-owner@lists.biostat.wustl.edu
In-reply-to: <cb444ad00901160951l7abe84ado69ab3d9d1956318c@mail.gmail.com>
References: <20090115112005.D3D7612427E@smtp.biostat.wustl.edu> <cb444ad00901160951l7abe84ado69ab3d9d1956318c@mail.gmail.com>

Doug,
  Is this what you want? You'll need to recreate the rownames.
Dave
t(as.data.frame(
    lapply(
      lapply(DATA, function(x, lag) acf(x,lag), lag=3),
    function(x) x$acf[,,1])))



Doug Bolgiano <dougb@psbcresearch.org>
Sent by: s-news-owner@lists.biostat.wustl.edu

01/16/2009 11:51 AM

To
s-news@lists.biostat.wustl.edu
cc
Subject
Re: [S] [s-news] S-News Daily Digest V2 #1954





extracting components from a list of lists

I use tapply with the acf function (lag =3) and the subject index of a data frame to calculate autocorrelations for a variable measured repeatedly on each subject (n = 180).  The result is a list of lists (which are the output of the acf function), one for each subject.  I want to extract the $acf component from each subject's list and form a matrix where rows index subjects and columns index lags.  

I have tried using the subscript operators [] and [[ ]] to extract the acf componets.  Do I have to resort to looping through the subject lists and extracting the acf component from each list individually or is there a more efficient way to do this?

Doug Bolgiano
Puget Sound Blood Center
Seattle, WA  98104


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