Re: [R] simplifying code

2012-12-17 Thread David Winsemius
On Dec 17, 2012, at 5:15 AM, Rui Barradas wrote: Hello, Try the following. cp <- sapply(1:4, function(n) output0*exp(-0.3*TIME1[n])) plot(TIME1, cp) That appears to be more complex than necessary. Even R-newbs should use vectorized approaches if they are easily available: cp <- outpu

Re: [R] simplifying code

2012-12-17 Thread Rui Barradas
Hello, Try the following. cp <- sapply(1:4, function(n) output0*exp(-0.3*TIME1[n])) plot(TIME1, cp) Hope this helps, Rui Barradas Em 17-12-2012 13:04, Andras Farkas escreveu: > Dear All, > > I was wondering if you could help me with the following: > I have the code: > > tin <-0.5 > tau <

Re: [R] simplifying code

2012-12-17 Thread Gergely Daróczi
Hello Andras, what about: plot(TIME1, output0*exp(-0.3*TIME1)) Best, Gergely On Mon, Dec 17, 2012 at 2:04 PM, Andras Farkas wrote: > Dear All, > > I was wondering if you could help me with the following: > I have the code: > > tin <-0.5 > tau <-24 > output0 <-10 > TIMELOW <-tin > TIMEHIGH <-1*

[R] simplifying code

2012-12-17 Thread Andras Farkas
Dear All,   I was wondering if you could help me with the following: I have the code:   tin <-0.5 tau <-24 output0 <-10 TIMELOW <-tin TIMEHIGH <-1*tau TIME1 <-c(seq(TIMELOW,TIMEHIGH, by = sign(TIMEHIGH-TIMELOW)*(tau-tin)/3))   then I would like to calculate:   cp1 <-output0*exp(-0.3*TIME1[1]) cp2 <