[R] Retrieve by Id from an R list

Petr Savicky savicky at cs.cas.cz
Mon Feb 13 10:59:34 CET 2012


On Mon, Feb 13, 2012 at 02:13:41PM +0530, Suranga Kasthurirathne wrote:
> Hi everyone,
> 
> I'm using the poLCA module for some analysis work.
> Basically, Im using the command >poLCA(f, data=response,nclass=2)
> 
> This returns a poLCA object (a list)
> 
> >From this data, I need to retrieve certain indexes, such as[[5]] as seen
> below.
> 
> [[5]]
>                    Pr(1)       Pr(2)       Pr(3)
> class 1:          0            1.0        0.0
> class 2:          0            0.5        0.5
>
> 1) The structure shown in [[5]] above is a matrix, isn't it ?
> 2) how can I specifically retrieve this matrix (retrieve by ID, I guess) ?

Hi.

If the list is in the variable "poLCA", then try

  a <- poLCA[[5]]
  a

Whether this is a matrix may be checked using

  class(a)

Hope this helps.

Petr Savicky.



More information about the R-help mailing list