Skip to content

Instantly share code, notes, and snippets.

@tomquisel
Created April 6, 2016 20:54
Show Gist options
  • Save tomquisel/545cc4e4d9e9abbb48aa0a84459079f4 to your computer and use it in GitHub Desktop.
Save tomquisel/545cc4e4d9e9abbb48aa0a84459079f4 to your computer and use it in GitHub Desktop.
def do_R_wilcoxon(before, after, paired=True, two_tailed=False):
b_mat = before.as_matrix()
a_mat = after.as_matrix()
alternative = 'g'
if two_tailed:
alternative = 'two.sided'
%R -i b_mat,a_mat,paired,alternative -o wilcox_res wilcox_res=wilcox.test(b_mat, a_mat, paired=paired, exact=TRUE, conf.int=TRUE, alternative=alternative)
#print list(enumerate(wilcox_res))
# this returns just the p-value and the conf interval
return {
'p-value': wilcox_res[2][0],
'95_conf_int': list(wilcox_res[7]),
'statistic': wilcox_res[0][0],
'before': before,
'after': after,
'pseudo_median': wilcox_res[8][0]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment