I have a dataframe as follows:
df <- data.frame(group = c("A", "B", "C", "D", "E"),
country=c("US","UK"),
md = runif(10,0,10),
og = runif(10, 0, 10))
and want to apply wilcox function in each row to compare md and og in each group and each country.
results <- apply(df,1,function(x){
df <- data.frame(x)
wres<-wilcox.test(df$md,df$og)
df$test<-format(wres$p.value,scientific = F)
})
I want to have another column consists of P-value. but when I run it it gives me the following error:
Error in wilcox.test.default(df$mean_modified, df$mean_original) :
'x' must be numeric