Hi, all. I'm sure this is a simple question, but I'm having problems figuring it out myself... I have a table:> currenttable <- table(junk[-1],junk[-n]) > currenttablebar foo junk bar 2 2 0 foo 1 0 0 junk 0 0 1 and I'd like to know the result of the cell currenttable(bar,foo). what is the best way to get that result? thanks! greg -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>From: Greg Trafton <trafton at itd.nrl.navy.mil> >Hi, all. I'm sure this is a simple question, but I'm having problems >figuring it out myself... I have a table: > >> currenttable <- table(junk[-1],junk[-n]) >> currenttable > > bar foo junk > bar 2 2 0 > foo 1 0 0 > junk 0 0 1 > >and I'd like to know the result of the cell currenttable(bar,foo).currenttable[1,2] or even table(junk[-1],junk[-n])[1,2] Jon Baron -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Tue, 10 Jul 2001, Greg Trafton wrote:> Hi, all. I'm sure this is a simple question, but I'm having problems > figuring it out myself... I have a table: > > > currenttable <- table(junk[-1],junk[-n]) > > currenttable > > bar foo junk > bar 2 2 0 > foo 1 0 0 > junk 0 0 1 > > and I'd like to know the result of the cell currenttable(bar,foo). > > what is the best way to get that result?currenttable["bar","foo"] I think you would be well advised to work through the "Introduction to R" manual, which will answer a lot of basic questions about programming. -thomas Thomas Lumley Asst. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>From trafton at viz.itd.nrl.navy.mil Tue Jul 10 15:43:07 2001 >>>>>> Jonathan Baron writes: > >>> From: Greg Trafton <trafton at itd.nrl.navy.mil> Hi, all. I'm sure >>> this is a simple question, but I'm having problems figuring it out >>> myself... I have a table: >>> >>> currenttable <- table(junk[-1],junk[-n]) >>> currenttable >>> >>> bar foo junk >>> bar 2 2 0 >>> foo 1 0 0 >>> junk 0 0 1 > >>> and I'd like to know the result of the cell currenttable(bar,foo). > >> currenttable[1,2] > >> or even > >> table(junk[-1],junk[-n])[1,2] > >Whoops! I should have been a bit more specific! sometimes foo is not >in the table, so I do not know exactly what row or column it is in; I >need to access it via the "headings" (rows and column names).The following works, although it may not work in every imaginable case: currenttable["foo","bar"] Jon -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Tue, 10 Jul 2001, Greg Trafton wrote:> Hi, all. I'm sure this is a simple question, but I'm having problems > figuring it out myself... I have a table: > > > currenttable <- table(junk[-1],junk[-n]) > > currenttable > > bar foo junk > bar 2 2 0 > foo 1 0 0 > junk 0 0 1 > > and I'd like to know the result of the cell currenttable(bar,foo). > > what is the best way to get that result? > > thanks! > greg > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >currenttable[match("bar",dimnames(currenttable)[[1]]), match("foo",dimnames(currenttable)[[2]])] -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._