On 14-01-05 3:47 PM, Mathew Nagendran wrote:
I'm relatively new to R. I'm trying to for loop but I keep getting an error 
message. Can anyone hint at what I am doing wrong please?

Nothing to do with the for loop. You have a call to your t function in which you don't specify a value for the a argument.

BTW, t() is a standard R function to transpose a matrix; it's not a good idea to use that as your own function name, because you'll end up confused later. It's better to use longer, more meaningful names. And if you'd done this for the arguments to your function it might have been more obvious what the error message was talking about.

Duncan Murdoch


m.control=c(1.45,9.40,9.96,4.2,1.86,0.2)
m.sham=c(3.39,23.94,23.62,10.08,2.99,1.09)

t=function(m, a){(1-exp(-a*m))} #t function defined

d=function(ts, tc){(ts-tc)/ts} #d function defined

pick.a=seq(0.01,2,by=0.01) #set of a values defined

output=cbind(pick.a,d=rep(NA,length(pick.a))) #define array containing a values 
in column 1 and d values (outputs) in column 2

for(count in 1:length(pick.a)){
+ ts=sum(t(m.sham),pick.a[count])
+ tc=sum(t(m.control),pick.a[count])
+ output[count,2]=(ts-tc)/ts
+ }
Error in -a : 'a' is missing


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to