Re: [R] classification tables

2006-08-07 Thread Philippe Grosjean

  x - c(1,2,3,4,2,3,3,1,2,3)
  y - c(2,1,3,4,1,3,3,2,2,3)
  table(x, y)
y
x   1 2 3 4
   1 0 2 0 0
   2 2 1 0 0
   3 0 0 4 0
   4 0 0 0 1
  ?table

Best,

Philippe Grosjean

..°}))
  ) ) ) ) )
( ( ( ( (Prof. Philippe Grosjean
  ) ) ) ) )
( ( ( ( (Numerical Ecology of Aquatic Systems
  ) ) ) ) )   Mons-Hainaut University, Belgium
( ( ( ( (
..

Taka Matzmoto wrote:
 Dear R-users
 
 I have two vectors. One vector includes true values and the other vector has 
 estimated values. Values are all integers from 1 to 4.
 
 For example,
 
 x - c(1,2,3,4,2,3,3,1,2,3)
 y - c(2,1,3,4,1,3,3,2,2,3)
 
 I would like to a classfication table x by y. With the table, I would like 
 to calculate what percentage is correct classfication.
 
 Which R function do I need to use for creating a 4 * 4 classification table?
 
 Thank you.
 
 Taka,
 
 __
 R-help@stat.math.ethz.ch 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.
 


__
R-help@stat.math.ethz.ch 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.


Re: [R] classification tables

2006-08-07 Thread Gabor Grothendieck
Also check out CrossTable in the gmodels package.

Regarding your other question, assuming we have
tab-table(x,y) as in Philippe's post, the fraction of
pairs in x and y that match can be calculated via
any of these:

  sum(x==y) / length(x)

  sum(diag(tab)) / sum(tab)

  library(e1071)
  classAgreement(tab) # tab from above

  sum(diag(prop.table(tab)))


On 8/7/06, Philippe Grosjean [EMAIL PROTECTED] wrote:

   x - c(1,2,3,4,2,3,3,1,2,3)
   y - c(2,1,3,4,1,3,3,2,2,3)
   table(x, y)
y
 x   1 2 3 4
   1 0 2 0 0
   2 2 1 0 0
   3 0 0 4 0
   4 0 0 0 1
   ?table

 Best,

 Philippe Grosjean

 ..°}))
  ) ) ) ) )
 ( ( ( ( (Prof. Philippe Grosjean
  ) ) ) ) )
 ( ( ( ( (Numerical Ecology of Aquatic Systems
  ) ) ) ) )   Mons-Hainaut University, Belgium
 ( ( ( ( (
 ..

 Taka Matzmoto wrote:
  Dear R-users
 
  I have two vectors. One vector includes true values and the other vector has
  estimated values. Values are all integers from 1 to 4.
 
  For example,
 
  x - c(1,2,3,4,2,3,3,1,2,3)
  y - c(2,1,3,4,1,3,3,2,2,3)
 
  I would like to a classfication table x by y. With the table, I would like
  to calculate what percentage is correct classfication.
 
  Which R function do I need to use for creating a 4 * 4 classification table?
 
  Thank you.
 
  Taka,
 
  __
  R-help@stat.math.ethz.ch 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.
 
 

 __
 R-help@stat.math.ethz.ch 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.


__
R-help@stat.math.ethz.ch 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.