Re: [R] Help with R: functions

2006-01-31 Thread Pryseley Assam
Dear R-users Thanks for all the help/suggestions, they have been most helpful. Best regards Pryseley - [[alternative HTML version deleted]] __

[R] Help with R: functions

2006-01-30 Thread Pryseley Assam
Hello R-users I am new to R and trying to write some functions. I have problems writing functions that takes a data set as an arguement and uses variables in the data. I illustrate my problem with a small example below: sample data #-- visual24-rnorm(30,3,5)

Re: [R] Help with R: functions

2006-01-30 Thread TEMPL Matthias
],rcc[2]) detach(data) } st(dats,visual24,visual52) Best, Matthias -Ursprüngliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Pryseley Assam Gesendet: Montag, 30. Jänner 2006 14:14 An: r-help@stat.math.ethz.ch Betreff: [R] Help with R

Re: [R] Help with R: functions

2006-01-30 Thread Philippe Grosjean
# Here it is (using the formula interface): dats - data.frame(visual24 = rnorm(30, 3, 5), visual52 = rt(30, 7)) st - function(formula, data, ...) { # Just use the formula to specify which variables to use rcc - coef(lm(formula, data)) # Make sure to

Re: [R] Help with R: functions

2006-01-30 Thread Jacques VESLOT
st - function(data, x, y){ attach(data) rcc - coef(lm(y~x)) plot(x,y) abline(rcc) detach(data)} st(data=dats, x=visual24, y=visual52) Pryseley Assam a écrit : Hello R-users I am new to R and trying to write some functions. I have problems writing functions that

Re: [R] Help with R: functions

2006-01-30 Thread Liaw, Andy
This might be a bit closer to what Pryseley wanted: st - function(dat, x, y) { f - formula(substitute(y ~ x), env=environment(dat)) plot(f, dat) abline(lm(f, dat)) } Note that the variable names in the plot when tested on `dats' as Pryseley created. Andy From: Jacques VESLOT st