His is better, but you can also use a for loop...

out<-data.frame(rows=1:3)
for(i in 1:3){
  if(l[[i]][3]=='Message 1') {
    out$V1[i]<-l[[i]][1]
  } else {
    out$V1[i]<-NA
  }
}

but shouldn't if your list is very long

On Tue, Aug 23, 2011 at 9:35 AM, Henrique Dallazuanna <wwwhsd@gmail.com>wrote:

> Try this:
>
> subset(as.data.frame(do.call(rbind, lapply(l, "[", , 1))), row3 == "Message
> 1")
>
> On Tue, Aug 23, 2011 at 1:28 PM, Lara Poplarski <larapoplarski@gmail.com>
> wrote:
> > Hi all,
> >
> > I have an object that looks (roughly) like the following:
> >
> > l <- list(a = matrix(rnorm(9), 3), b = matrix(rnorm(9), 3), c =
> > matrix(rnorm(9), 3))
> >
> > l$a[3,] <- sample(c("Message 1", "Message 2", "Message 3"))
> > l$b[3,] <- sample(c("Message 1", "Message 2", "Message 3"))
> > l$c[3,] <- sample(c("Message 1", "Message 2", "Message 3"))
> >
> > rownames(l$a) <- rownames(c(1:3), do.NULL = FALSE, prefix = "row")
> > rownames(l$b) <- rownames(c(1:3), do.NULL = FALSE, prefix = "row")
> > rownames(l$c) <- rownames(c(1:3), do.NULL = FALSE, prefix = "row")
> >
> > colnames(l$a) <- c("V1", "V2", "V3")
> > colnames(l$b) <- c("V1", "V2", "V3")
> > colnames(l$c) <- c("V1", "V2", "V3")
> >
> > I want to extract values (row1, V1) for the three sublists a, b, c,
> > but only for those cases in which row3 == "Message 1". Could someone
> > suggest how to proceed?
> >
> > Many thanks in advance,
> > Lara
> >
> > ______________________________________________
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
>
> --
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]

