Wilcoxon test wont go right

so ive been trying to analyse my non parametric data for a while however I cant seem to get it to work - basically I've been trying to run a post hoc to a kruskal wallis test. however I don't know whats wrong whether its my data layout of my inputs

Stat.testFvFm0N1 <- FvFm0N %>%

  • wilcox.test(D0 ~ D1, paired = TRUE) %>% add_significance()
    Error in wilcox.test.default(., D0 ~ D1, paired = TRUE) :
    'x' must be numeric

Stat.testFvFm0H1 <- FvFm0H %>% wilcox.test(D0 ~ D1, paired = TRUE) %>% add_significance()
Error in wilcox.test.default(., D0 ~ D1, paired = TRUE) :
'x' must be numeric
Stat.testFvFm0H1 <- FvFm0H %>% wilcox.test(FvFm ~ D0*D1, paired = TRUE) %>% add_significance()
Error in wilcox.test.default(., FvFm ~ D0 * D1, paired = TRUE) :
'x' must be numeric
Stat.testFvFm0H1 <- FvFm0H %>% wilcox.test(FvFm ~ Day, paired = TRUE) %>% add_significance()
Error in wilcox.test.default(., FvFm ~ Day, paired = TRUE) :
'x' must be numeric
Stat.testFvFm0H1 <- FvFm0H %>% group_by(Day) %>% wilcox.test(FvFm ~ Day, paired = TRUE) %>% add_significance()
Error: Must group by variables found in .data.

  • Column Day is not found.
    Run rlang::last_error() to see where the error occurred.

Stat.testFvFm0H1 <- FvFm0H %>% group_by("Day") %>% wilcox.test(FvFm ~ Day, paired = TRUE) %>% add_significance()
Error in wilcox.test.default(., FvFm ~ Day, paired = TRUE) :
'x' must be numeric
I've split my data up into different conditions for the exact same IPAM parameter to do a paired test between the days, however I don't know whats going on because my data points are numeric except there are more then two data sets in the table but can't seem to focus in on two at a time - I just don't want to have to keep importing data sets with less data in
D0 D1 D2 D3 D4 D5 D6 D7
1 0.163457469 0.187385368 0.136679322 0.10488145 0.110073797 0.095678447 0.094178232 0.106127771
2 0.142494136 0.181154612 0.143094261 0.105833764 0.104921535 0.097943358 0.087377843 0.104797048
3 0.131960693 0.175194359 0.149937526 0.114355231 0.095977698 0.083587252 0.088176672 0.105426727
this is how my data is laid out originally or I've tried to make the data long and that hasn't worked either

I hope this helps

require(graphics)
## One-sample test.
## Hollander & Wolfe (1973), 29f.
## Hamilton depression scale factor measurements in 9 patients with
##  mixed anxiety and depression, taken at the first (x) and second
##  (y) visit after initiation of a therapy (administration of a
##  tranquilizer).
x <- c(1.83,  0.50,  1.62,  2.48, 1.68, 1.88, 1.55, 3.06, 1.30)
y <- c(0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29)
depression <- data.frame(first = x, second = y, change = y - x)

wilcox.test(change ~ 1, data = depression) #works
library(magrittr)
depression %>% wilcox.test(change ~ 1) #doesnt work, dont assume that data= is first param which is what the pipe relies on by default

depression %>% wilcox.test(data=.,change ~ 1) #works again use . to play the result of piping

Its ok Ive sorted it, instead of going through each time and writing X and Y values if there a way to exact certain values from my table and put them into a new data frame? i know how to merg data frames but not copy over, if this makes sense so i want the data to stay in the original data frame but also want to make a new data frame with them in

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

I don't know what you are doing but maybe

 wilcox.test(FvFm0H$D0 ,FvFm0H$D1, paired = TRUE) 

but then not sure what add_significance() relates to or is trying to accomplish

1 Like

FvFm0N1 <- wilcox.test(data = FvFm0N, FvFm ~ Day )
Error in wilcox.test.formula(data = FvFm0N, FvFm ~ Day) :
grouping factor must have exactly 2 levels
FvFm0N1 <- wilcox.test(data = FvFm0N, FvFm ~ D0*D1 )
Error in wilcox.test.formula(data = FvFm0N, FvFm ~ D0 * D1) :
'formula' missing or incorrect
x <- c(0.16345747, 0.14249414, 0.13196069)
y <- c(0.18738537, 0.18115461, 0.17519436)
FvFm0N1 <- data.frame(first = x, second = y)
FvFm0N1
first second
1 0.1634575 0.1873854
2 0.1424941 0.1811546
3 0.1319607 0.1751944
res.wk.0N1P <- FvFm0N1 %>% wilcox.test(data = ., first ~ second)
Error in wilcox.test.formula(data = ., first ~ second) :
grouping factor must have exactly 2 levels
FvFm0N1 <- FvFm0N1 %>% gather(key = "Day", value = "FvFm", first, second)
FvFm0N1
Day FvFm
1 first 0.1634575
2 first 0.1424941
3 first 0.1319607
4 second 0.1873854
5 second 0.1811546
6 second 0.1751944
res.wk.0N1P <- FvFm0N1 %>% wilcox.test(data = ., first ~ second)
Error in eval(predvars, data, env) : object 'second' not found
res.wk.0N1P <- wilcox.test(data = FvFm0N1, Day ~ FvFm)
Error in wilcox.test.formula(data = FvFm0N1, Day ~ FvFm) :
grouping factor must have exactly 2 levels

Ive tried to do what youve said but now its sayin i need exactly two levels so i have no idea what to do