[R] sensitivity and specificity

David Winsemius dwinsemius at comcast.net
Fri Apr 25 20:09:22 CEST 2014


On Apr 25, 2014, at 10:58 AM, Si Qi L. wrote:

> Hi guys,
> 
> I will be very grateful if you guys can do me a little favor on R. I am
> calculating the sensitivity and specificity for a 2*2 matrix, such as
> 
> t
>       0    1
>  0 1427  110
>  1  271  166
> 
> 
> 
> My codes are:   sens <- function(ct) { ct[2,2] / sum(ct[,2]) }
>                          spec <- function(ct) { ct[1,1] / sum(ct[,1]) }
> 
> But it doesn't show any numerical results.

What is the "it" that doesn't show any results? You show no code that uses these functions and you don't even include a reproducible example for `t`. 

(BTW using 't' as an object name may cause confusion since t() is a commonly used matrix function.


> Would you please help me to fix
> it? Mnay thanks for your help.:)
> 
> Best regards,
> 
> Siqi
> 
> 	[[alternative HTML version deleted]]

And please take the time to read the Posting Guide and learn to post in plain text as requested there.

> 
> ______________________________________________
> R-help at r-project.org 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.

David Winsemius
Alameda, CA, USA




More information about the R-help mailing list