[R] Extracting values in table

Bert Gunter gunter.berton at gene.com
Fri Aug 26 19:15:20 CEST 2011


Ramnath:

With my apologies if I'm wrong, it does not look like you have made
much of an effort to learn R's basics, e.g. by working thru the
"Introduction to R" tutorial distributed with R. If that is the case,
why do you expect us to help?

-- Bert

On Fri, Aug 26, 2011 at 8:52 AM, Ramnath <sairam.bt at gmail.com> wrote:
> Hi All,
>
> I am a beginner in programming in r and please do forgive me if my question
> seems to be silly and sometimes not understandable.
>
> 1. we have a list of elements in a list say:
>
> ls<-list("N","E","E","N","P","E","M","Q","E","M")
>
> 2. We have an another list of tables in a list say:
>
> n <- list("M", "N","E","P","Q","M","N","E","Q","N")
>
> tb <- lapply(1:10, function(i)matrix(sample(4), 2, 2,
> dimnames=list(n[sample(10,2)], n[sample(2,2)])))
>
> 3. we need to extract values from the table in the list where colname is
> always "M" , wherein the rowname should be the 1st element in the list ls
> for table 1 in the list tb and 2nd element in table 2 and so on...
>
> for ex:
>   M N
> N 4 1
> P 3 2
>
> In table 1 , we need to extract value 4.
>
>
> Thanks to all in advance.
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Extracting-values-in-table-tp3771272p3771272.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
>



-- 
"Men by nature long to get on to the ultimate truths, and will often
be impatient with elementary studies or fight shy of them. If it were
possible to reach the ultimate truths without the elementary studies
usually prefixed to them, these would not be preparatory studies but
superfluous diversions."

-- Maimonides (1135-1204)

Bert Gunter
Genentech Nonclinical Biostatistics



More information about the R-help mailing list