Hi Michael and Sarah,
Thank you for offering help. I finally managed to construct an example with all
essentials of my problem:
x1<-c(1,2,3,4)
x2<-c(2,3,4,5)
x3<-c(3,4,5,6)
x<-rbind(x1,x2,x3)
time<-c(1,3,9)
fit<-function(xx,t,tcc){slope <- coefficients(lm(log(xx) ~ 0 + t))[1]
alpha<-slope-log(2)/tcc
return(alpha)
}
alpha<-fit(x,time,20)
At the moment the function output 'alpha' is calculated for x(x1=1,x2=2,x3=3).
I would like to get 'alphas' for all four rows of x without using a for-loop.
Is there any possibility to avoid a for-loop?
Thank you very much in advance,
Stella
Von: Sarah Goslee <[email protected]>
An: R. Michael Weylandt <[email protected]>
CC: stella <[email protected]>; [email protected]
Gesendet: 17:14 Donnerstag, 22.März 2012
Betreff: Re: [R] How to get the input of a function right?
On Thu, Mar 22, 2012 at 11:55 AM, R. Michael Weylandt
<[email protected]> wrote:
> This is quite difficult without being able to see the function f .....
>
> Michael
I thought we had a fortune about telepathy, but I can't find it in the
fortunes package.
Sarah
--
Sarah Goslee
http://www.functionaldiversity.org
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.