Search code examples
rasbio

Write results in table to one row in R


I have made a Kappa statistic {Asbio}.

library("asbio")
reference<-c("hi","low","low","hi","low","med","med")
class1<-c("hi","hi","low","hi","med","med","med")
Kappa(class1,reference)

so the results is:

$ttl_agreement
[1] 71.42857

$user_accuracy
hi   low   med 
100.0  33.3 100.0 

$producer_accuracy
hi   low   med 
 66.7 100.0  66.7 

$khat
[1] 58.8

$table
      reference
class1 hi low med
   hi   2   1   0
   low  0   1   0
   med  0   1   2

What I want is to save this result into table as:

ttl_agreement  user_accuracy_hi user_accuracy_low user_accuracy_med  ... etc. 
 71.42857            100.0           100.0             100           

so "defregmentate" my results and put them in one table row (with column name). I would like to make repeat Kappa maybe for 100 times. Maybe my question is trivial, but I cant really find the answer... Thanks in advance


Solution

  • Try unlist(Kappa(class1,reference)) which gives you a simple (named) vector, which you can easily coerce to a table using as.table(), if you wish. This works because Kappa() returns a list which can be unlisted to a simple vector.