Hey guys. The idea is I want to create a nested for.loop using pick.a values 
and m.control and m.sham at trunc1 to trunc6. How would I go about defining an 
array for this? I am unsure about what to put into length( ). In my last 
assignment it was a little bit more straightforward since I had:


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

pick.d=seq(0.01,1,by0.01) #set of d values defined

output=array(NA,c(length(pick.a), length(pick.d))) ?

-----------------------------------------------------------------------------------------------------------------------------------------


#--New work here--#


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.control=function(m, a){(1-exp(-a*m))*((1-(1/30)*m))}

t.ratio=function(ts, tc){(ts/tc)}

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


trunc1=-6

trunc2=c(-5,-6)

trunc3=c(-4,-5,-6)

trunc4=c(-3,-4,-5,-6)

trunc5=c(-2,-3,-4,-5,-6)

trunc6=c(-1,-2,-3,-4,-5,-6)


output=array(NA,c(length(pick.a), length()))


for(count in 1:length(pick.a)){

for(count1 in 1:6){

if(count1==1){trunc=trunc1}

if(count1==2){trunc=trunc2}

if(count1==3){trunc=trunc3}

if(count1==4){trunc=trunc4}

if(count1==5){trunc=trunc5}

if(count1==6){trunc=trunc6}

  ts1=sum(t.control(m.sham[trunc],pick.a[count]))

  tc1=sum(t.control(m.control[trunc],pick.a[count]))

output[count,count1]=(ts1/tc1)

}

}

dim(output)

print(output)


        [[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.

Reply via email to