[R] Passing arguments to with()
Tymek Wołodźko
tymek at wolodzko.com
Wed Jul 8 16:01:17 CEST 2009
Hi,
I've been wondering how to write a function that will produce results
from multiple tests (eg. paired t-tests) for all or several variables
in some data frame. I'd like it to do t-test for each variable ('x')
in 'data' by 'y'. I'm stuck in here:
function(data,y) {
for (x in names(data)) {
with(data, t.test(x~y))
}}
How to tell 'with' that 'x' and 'y' are names of columns in 'data'? Or
pass similar arguments?
I probably understand the logic why this is not working, but still
don't know how to make it work.
Thanks in advance for any help!
Timo
More information about the R-help
mailing list