【问题标题】:Issue in extracting a specific column from psych::alpha output从 psych::alpha 输出中提取特定列的问题
【发布时间】:2021-08-23 03:33:05
【问题描述】:
library(mirt) #this contains a dataset called deAyala.
library(psych) #this contains the alpha() function.
alpha(deAyala) 

使用这个函数可以得到以下数据集:

Some items ( Item.4 Item.5 ) 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
Reliability analysis   
Call: alpha(x = deAyala)

  raw_alpha std.alpha G6(smc) average_r  S/N     ase mean  sd
   0.00097      0.21    0.32     0.042 0.27 0.00057  103 134
 median_r
        0

 lower alpha upper     95% confidence boundaries
0 0 0 

 Reliability if an item is dropped:
          raw_alpha std.alpha G6(smc) average_r   S/N
Item.1      5.9e-05     0.019   0.057    0.0038 0.019
Item.2      6.5e-04     0.178   0.293    0.0414 0.216
Item.3      8.4e-04     0.220   0.342    0.0535 0.283
Item.4      1.2e-03     0.289   0.385    0.0750 0.406
Item.5      1.3e-03     0.306   0.387    0.0812 0.442
Frequency   0.0e+00     0.000   0.000    0.0000 0.000
          alpha se var.r med.r
Item.1     0.00056 0.011     0
Item.2     0.00055 0.044     0
Item.3     0.00054 0.047     0
Item.4     0.00052 0.044     0
Item.5     0.00051 0.041     0
Frequency  0.27951 0.000     0

 Item statistics 
           n raw.r std.r  r.cor r.drop  mean     sd
Item.1    32  0.60  0.59  0.657   0.60   0.5   0.51
Item.2    32  0.22  0.45  0.202   0.22   0.5   0.51
Item.3    32  0.10  0.41  0.080   0.10   0.5   0.51
Item.4    32 -0.11  0.33 -0.059  -0.11   0.5   0.51
Item.5    32 -0.17  0.31 -0.079  -0.17   0.5   0.51
Frequency 32  1.00  0.61  0.722   0.29 612.5 804.25

Non missing response frequency for each item
         0   1 miss
Item.1 0.5 0.5    0
Item.2 0.5 0.5    0
Item.3 0.5 0.5    0
Item.4 0.5 0.5    0
Item.5 0.5 0.5    0

我只想要项目统计表中的raw.r 列([1:6] 0.6 0.223 0.103 -0.112 -0.174),并且我想将它们存储在一个变量中。我怎样才能做到这一点?我尝试了以下方法:

str(alpha(deAyala)$item.stats$raw.r)

但这给了我很多文字:

Some items ( Item.4 Item.5 ) 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 num [1:6] 0.6 0.223 0.103 -0.112 -0.174 ...
Warning message:
In alpha(deAyala) :
  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

【问题讨论】:

    标签: r psych


    【解决方案1】:

    您可以通过使用suppressWarnings() 包装来消除警告位,但消息的第一位看起来只是alpha() 函数中的打印语句。这会起作用

    invisible(capture.output(x <- suppressWarnings(alpha(deAyala)$item.stats$raw.r)))
    

    编辑:实际上我只是查看了alpha 的帮助,它有一个warnings 选项,您可以将其设置为FALSE

    【讨论】:

    • 第一种方法效果很好。我尝试了第二种方法并将警告设置为假,这给了我这个输出。我怎样才能正确存储这个? imgur.com/a/fLmO79F
    • 不知何故这在我的控制台中有效,但在我的 Shiny 应用程序中不起作用。不过谢谢
    • str() 用于显示对象的结构,而不是用于访问它的一部分。你可以像我的回答一样放弃它。
    猜你喜欢
    • 2019-09-08
    • 2021-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-09
    相关资源
    最近更新 更多