0

I tried to run a statistical test on 2 data samples

wilcox.test(data.strain1$Discrimination_ratio, data.strain2$Discrimination_ratio, paired=TRUE)

Error in wilcox.test.default(data.strain1$Discrimination_ratio, data.strain2$Discrimination_ratio,  : 
'x' must be numeric

I think this is because my data has ',' instead of'.' as decimal separator. How can I fix the problem? Thanks

data.strain1

No. Discrimination_Ratio
11  5,60
12  2,40
13  14,40
14  10,80
21  3,50
22  2,60
23  1,70
24  4,20
25  4,60
51  0,50
52  2,60
53  1,20
54  3,00
55  17,70
82  4,40
26  -0,70
83  9,30

data.strain2

No. Discrimination_Ratio
21  8,2
22  6,7
23  0
24  -2,8
25  20,7
82  0
26  6,7
83  2,7
62  0
66  8,9
67  -5,4
68  1,4
69  -1,1
44  1,3
45  8,5
46  5,2
47  1,9
Jung
  • 139
  • 6
  • Try replacing the , with . and converting to numeric: `as.numeric(gsub(",", ".",data.strain1$Discrimination_ratio))` – Dave2e Aug 17 '19 at 17:34
  • 1
    While `sub` will work (both in @Dave2e's comment and in some answers in the link), the more-generic solution is to use the correct "locale" when importing: `read.csv2` defaults to `sep=";",dec=","`, which is likely how your data is structured in its file. BTW: b/c of your problem, it shows that your data is non-numeric, which isn't going to work for most of your tests. To verify, do `str(data.strain1)`, and it will likely show `factor` or `chr` (`character`) for your second column. Fixing the *symptom* (with `sub`) is good, fixing the *problem* is much better, as it may prevent others, too. – r2evans Aug 17 '19 at 17:52

0 Answers0