程序:R 3.2.1 for Mac OSX
IDE:RStudio
输出:rmkd > html
包:“psych”
功能:alpha()
问题:
使用alpha(data, na.rm=F, check.keys=F, delete=F)
时,由于部分输入数据是负相关的,并且因为我有 check.keys = FALSE,我收到以下消息:
有些项目XXX与总量表呈负相关,可能应该颠倒过来。为此,请使用“check.keys=TRUE”选项再次运行该函数
问题:
我的 check.keys 是故意设置的。完全理解警告的含义,主要是出于审美和教育原因,我怎样才能在输出中抑制它?
到目前为止的尝试:
1.我试过suppressWarnings()
& suppressMessages()
。
2. 我试过invisible()
& sink(., type="message")
。
3. 在 Rmd 块中,我尝试过:```{r warning=F, message=F}
4. 探索print(alpha)
我发现了我认为的起源。也许有人知道如何抑制这部分代码?:
`p1 <- principal(x)
if (any(p1$loadings < 0)) {
if (check.keys) {
warning("Some items were negatively correlated with total scale and were automatically reversed.\n This is indicated by a negative sign for the variable name.")
keys <- 1 - 2 * (p1$loadings < 0)
}
else {
warning("Some items were negatively correlated with the total scale and probably should be reversed. To do this, run the function again with the 'check.keys=TRUE' option")
cat("Some items (", rownames(p1$loadings)[(p1$loadings < 0)], ") were negatively correlated with the total scale and probably should be reversed. To do this, run the function again with the 'check.keys=TRUE' option")
}
}`
谢谢!