[R] calculating percent error from 2 vectors

Scott Bearer sbearer at tnc.org
Thu Jul 12 19:32:03 CEST 2007


I believe this is an easy scripting problem, but one I am stumbling on.

I have a "known" vector of 3 colors with nrow=10:
known<-c("red", "blue", "red", "red", "yellow", "blue", "yellow", "blue",
"blue", "yellow")

and a model output vector:
modelout<-c("red", "red", "red", "blue", "yellow", "blue", "blue", "red",
"blue", "yellow")

I would like to determine the proportion (in)correctly identified for each
color.  In other words:
% correct "red"=
% correct "blue"=
% correct "yellow"=

How would I code this (assuming the actual dataset is more complex)?

Any help would be much appreciated.

Thank you,

More information about the R-help mailing list