[R] Please Please Please Help me!!
Liviu Andronic
landronimirc at gmail.com
Wed Jan 20 11:47:26 CET 2010
Hello
On Wed, Jan 20, 2010 at 7:00 AM, Madhavi Bhave <madhavi_bhave at yahoo.com> wrote:
> Sir, I am not asking for the modification of existing code as it is running fine with a single set of data (and I have checked that the output tallies with other methods). I just want to use this code for multiple data so that I get an output something like
>
> maculay_duration modified_duration
>
> 1423.797 1423.795
>
> 44.339 44.307
>
I am not sure that this would be the most efficient, but see if
something similar does the job for you:
x <- matrix(NA, 5,2); x
for (i in 1:5){
x1 <- cbind(mean(rnorm(100)), mean(runif(100))) ## use duration()
instead of cbind() and r*() funs
x[i, ] <- x1
}
x
Liviu
More information about the R-help
mailing list