尝试计算中位数时出错

我正在写硕士论文,需要使用R进行一些统计计算。由于一般的统计信息和R对我来说都不是我所熟悉的东西,因此我观看了“ how-to” youtube视频并在互联网上的一些Excel数据示例中进行了练习。掌握了这一点之后,我冒险进入自己的数据,但没有成功。 因此,我需要计算每个问题的李克特量表给出的答案的中位数。 当我尝试在R中计算此值时,出现“需要数字数据”的“错误”。我真的不明白哪里出了问题。 我知道这是“基本的”,但是我是统计/ R的新手。

  Sub Groep Behandeling X1.1 X1.2 X1.3 X1.4 X1.5 X1.6
1  21    BE           1    3    5    5    3    5    5
2  31    BE           1    4    5    5    2    5    5
3  33  BEBD           1    4    5    5    4    5    2
4  44    BE           1    3    5    5    3    5    5
5  47    BE           1    5    4    5    1    4    3
6  48    BE           1    5    2    4    1    4    5



library(xlsx)
library(dplyr)    
#Inlezen Exel sheet: 'testTAQ'----    
TestTAQ <- read.xlsx("Questionnaires_Results.xlsx" , sheetIndex = 6)
#rij 1 wil ik weg     
TAQ <- TestTAQ[2:31, ]
TAQ

#groep maken met alleen BE en BEBD     
TAQ <- TAQ %>% filter(Groep == "BE" | Groep == "BEBD")    
TAQ

#Subgroep maken met behandeling vs geen behandeling ----
#voor behandeling vs niet behandeling alleen kolommen voor vragen die bevraagd waren in die subgroep toegevoegd    
##behandeling 
TAQBehandeling <- TAQ %>% select(1:9) %>% filter(Behandeling ==1)
##geen behandeling 
TAQGeenbehandeling <- TAQ %>% select(1, 2, 10:32) %>% filter(Niet_Behandeling ==1)
TAQGeenbehandeling

#Mediaan berekenen ----
##TAQBehandeling     
summarise(TAQBehandeling, median_X1.1 = median(X1.1))
摘要(TAQBehandeling,中位数X1.1 =中位数X1.1)   错误:评估错误:需要数字数据。
 str(Testtaq)             
    'data.frame':   41 obs. of  32 variables:
     $ Sub             : Factor w/ 41 levels "1","21","22",..: 41 2 3 4 5 6 7 8 1 9 ...
     $ Groep           : Factor w/ 3 levels "BD","BE","BEBD": NA 2 1 2 2 3 2 2 2 2 ...
     $ Behandeling     : num  0.154 1 0 0 0 ...
     $ X1.1            : Factor w/ 4 levels "3","4","5","NA": 2 1 4 4 4 4 4 4 4 2 ...
     $ X1.2            : Factor w/ 4 levels "2","4","5","NA": 3 3 4 4 4 4 4 4 4 3 ...
     $ X1.3            : Factor w/ 3 levels "4","5","NA": 2 2 3 3 3 3 3 3 3 2 ...
     $ X1.4            : Factor w/ 6 levels "1","2","2.5",..: 3 4 6 6 6 6 6 6 6 2 ...
     $ X1.5            : Factor w/ 3 levels "4","5","NA": 2 2 3 3 3 3 3 3 3 2 ...
     $ X1.6            : Factor w/ 4 levels "2","3","5","NA": 3 3 4 4 4 4 4 4 4 3 ...
     $ Niet_Behandeling: num  0.846 0 1 1 1 ...
     $ X2.1            : Factor w/ 6 levels "1","2","3","4",..: 3 6 5 2 1 2 2 2 2 6 ...
     $ X2.2            : Factor w/ 6 levels "1","2","3","4",..: 2 6 1 4 4 2 1 3 1 6 ...
     $ X2.3            : Factor w/ 6 levels "1","2","3","4",..: 4 6 5 2 2 4 4 4 4 6 ...
     $ X2.4            : Factor w/ 6 levels "1","2","3","4",..: 2 6 1 1 1 2 4 1 2 6 ...
     $ X2.5            : Factor w/ 5 levels "1","2","3","4",..: 1 5 1 1 1 2 2 3 1 5 ...
     $ X2.6            : Factor w/ 5 levels "1","2","3","4",..: 3 5 1 1 1 2 4 4 3 5 ...
     $ X2.7            : Factor w/ 6 levels "1","2","3","4",..: 2 6 1 2 1 4 4 1 3 6 ...
     $ X2.8            : Factor w/ 6 levels "1","2","3","4",..: 3 6 1 4 1 4 4 4 4 6 ...
     $ X2.9            : Factor w/ 5 levels "1","2","3","4",..: 1 5 1 1 1 3 1 2 1 5 ...
     $ X2.10           : Factor w/ 6 levels "1","2","3","4",..: 1 6 1 1 1 3 1 4 1 6 ...
     $ X2.11           : Factor w/ 5 levels "1","2","3","5",..: 1 5 1 1 1 3 4 1 1 5 ...
     $ X2.12           : Factor w/ 4 levels "1","2","3","NA": 1 4 1 1 1 3 1 1 1 4 ...
     $ X2.13           : Factor w/ 5 levels "1","2","3","5",..: 1 5 1 4 1 3 1 1 1 5 ...
     $ X2.14           : Factor w/ 4 levels "1","2","3","NA": 1 4 1 1 1 3 1 1 1 4 ...
     $ X2.15           : Factor w/ 4 levels "1","2","3","NA": 1 4 1 1 1 3 1 1 1 4 ...
     $ X2.16           : Factor w/ 5 levels "1","2","3","4",..: 1 5 1 1 1 3 1 1 3 5 ...
     $ X2.17           : Factor w/ 5 levels "1","2","3","4",..: 1 5 1 1 1 3 1 1 1 5 ...
     $ X2.18           : Factor w/ 6 levels "1","2","3","4",..: 1 6 1 4 4 4 1 1 3 6 ...
     $ X2.19           : Factor w/ 6 levels "1","2","3","4",..: 1 6 1 1 3 4 4 1 4 6 ...
     $ X2.20           : Factor w/ 5 levels "1","2","3","4",..: 1 5 1 1 2 3 3 1 3 5 ...
     $ X2.21           : Factor w/ 6 levels "1","2","3","4",..: 4 6 5 2 1 4 2 2 5 6 ...
     $ X2.22           : Factor w/ 4 levels "1","3","4","NA": 1 4 1 3 1 2 3 1 2 4 ...

str(TAQGeenbehandeling)
'data.frame':   14 obs. of  25 variables:
 $ Sub             : Factor w/ 41 levels "1","21","22",..: 4 5 6 7 8 1 10 12 13 14 ...
 $ Groep           : Factor w/ 3 levels "BD","BE","BEBD": 2 2 3 2 2 2 3 2 2 2 ...
 $ Niet_Behandeling: num  1 1 1 1 1 1 1 1 1 1 ...
 $ X2.1            : Factor w/ 6 levels "1","2","3","4",..: 2 1 2 2 2 2 1 2 3 4 ...
 $ X2.2            : Factor w/ 6 levels "1","2","3","4",..: 4 4 2 1 3 1 4 5 3 5 ...
 $ X2.3            : Factor w/ 6 levels "1","2","3","4",..: 2 2 4 4 4 4 2 4 4 1 ...
 $ X2.4            : Factor w/ 6 levels "1","2","3","4",..: 1 1 2 4 1 2 4 4 2 3 ...
 $ X2.5            : Factor w/ 5 levels "1","2","3","4",..: 1 1 2 2 3 1 1 4 1 2 ...
 $ X2.6            : Factor w/ 5 levels "1","2","3","4",..: 1 1 2 4 4 3 4 3 3 4 ...
 $ X2.7            : Factor w/ 6 levels "1","2","3","4",..: 2 1 4 4 1 3 1 4 2 4 ...
 $ X2.8            : Factor w/ 6 levels "1","2","3","4",..: 4 1 4 4 4 4 4 4 2 4 ...
 $ X2.9            : Factor w/ 5 levels "1","2","3","4",..: 1 1 3 1 2 1 1 4 3 1 ...
 $ X2.10           : Factor w/ 6 levels "1","2","3","4",..: 1 1 3 1 4 1 5 3 1 1 ...
 $ X2.11           : Factor w/ 5 levels "1","2","3","5",..: 1 1 3 4 1 1 1 3 1 3 ...
 $ X2.12           : Factor w/ 4 levels "1","2","3","NA": 1 1 3 1 1 1 3 3 1 2 ...
 $ X2.13           : Factor w/ 5 levels "1","2","3","5",..: 4 1 3 1 1 1 1 3 3 1 ...
 $ X2.14           : Factor w/ 4 levels "1","2","3","NA": 1 1 3 1 1 1 1 2 1 1 ...
 $ X2.15           : Factor w/ 4 levels "1","2","3","NA": 1 1 3 1 1 1 1 1 1 1 ...
 $ X2.16           : Factor w/ 5 levels "1","2","3","4",..: 1 1 3 1 1 3 1 3 1 4 ...
 $ X2.17           : Factor w/ 5 levels "1","2","3","4",..: 1 1 3 1 1 1 1 3 1 4 ...
 $ X2.18           : Factor w/ 6 levels "1","2","3","4",..: 4 4 4 1 1 3 1 3 1 5 ...
 $ X2.19           : Factor w/ 6 levels "1","2","3","4",..: 1 3 4 4 1 4 1 3 1 4 ...
 $ X2.20           : Factor w/ 5 levels "1","2","3","4",..: 1 2 3 3 1 3 4 3 1 4 ...
 $ X2.21           : Factor w/ 6 levels "1","2","3","4",..: 2 1 4 2 2 5 2 4 3 1 ...
 $ X2.22           : Factor w/ 4 levels "1","3","4","NA": 3 1 2 3 1 2 1 2 2 1 ...