R tricks >

Use a string as variable name in a formula

The key is to use get():

wilcox.test(temp ~ activ, data = beaver1)

x <- "activ"
wilcox.test(temp ~ get(x), data = beaver1)