[R] calculating percent error from 2 vectors
Greg Snow
Greg.Snow at intermountainmail.org
Thu Jul 12 20:53:01 CEST 2007
Try something like:
> mytable <- table(known, modelout)
> prop.table( mytable, 1 )
Also look at ?addmargins and the CrossTable function in the gmodels
package.
Hope this helps,
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Scott Bearer
> Sent: Thursday, July 12, 2007 11:32 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] calculating percent error from 2 vectors
>
> Hello,
>
> 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,
> Scott
>
> ______________________________________________
> R-help at 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.
>
More information about the R-help
mailing list