[R] Turning off warnings from cor.test
Martin Maechler
maechler at stat.math.ethz.ch
Fri Apr 17 10:13:37 CEST 2009
>>>>> "DR" == Dimitris Rizopoulos <d.rizopoulos at erasmusmc.nl>
>>>>> on Fri, 17 Apr 2009 09:44:49 +0200 writes:
DR> check option 'warn' in the on-line help file of ?options(), e.g., you
DR> can use something like this:
DR> op <- options(warn = (-1)) # suppress warnings
DR> cor.test(c(1,2,3,3,4,5), c(1,2,3,3,4,5), method = "spearman")
DR> options(op) # reset the default value, if you want
[yes, do that!]
To make this more self-contained and error-proof, there
has been the function suppressWarnings(.) for several years now.
Hence, I'd strongly recommend
suppressWarnings( cor.test(c(1,2,3,3,4,5), c(1,2,3,3,4,5),
method = "spearman") )
instead of the above.
Regards,
Martin Maechler, ETH Zurich
DR> I hope it helps.
DR> Best,
DR> Dimitris
DR> Daren Tan wrote:
>> I would like to turn off the warnings from cor.test while retaining
>> exact=NULL. Is that possible ?
>>
>>> cor.test(c(1,2,3,3,4,5), c(1,2,3,3,4,5), method = "spearman")
>>
>> Spearman's rank correlation rho
>>
>> data: c(1, 2, 3, 3, 4, 5) and c(1, 2, 3, 3, 4, 5)
>> S = 0, p-value < 2.2e-16
>> alternative hypothesis: true rho is not equal to 0
>> sample estimates:
>> rho
>> 1
>>
>> Warning message:
>> In cor.test.default(c(1, 2, 3, 3, 4, 5), c(1, 2, 3, 3, 4, 5), method =
>> "spearman") :
>> Cannot compute exact p-values with ties
>>
>> ______________________________________________
>> 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.
>>
DR> --
DR> Dimitris Rizopoulos
DR> Assistant Professor
DR> Department of Biostatistics
DR> Erasmus University Medical Center
DR> Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
DR> Tel: +31/(0)10/7043478
DR> Fax: +31/(0)10/7043014
DR> ______________________________________________
DR> R-help at r-project.org mailing list
DR> https://stat.ethz.ch/mailman/listinfo/r-help
DR> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
DR> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list