[R] help

jim holtman jholtman at gmail.com
Fri Oct 15 04:53:30 CEST 2010


you probably want to use 'unlist'; can not test since you did not
provide a reproducible script:

for (i in 1:length(x)){result[,i] <- unlist(f(x[i]))}

On Thu, Oct 14, 2010 at 5:50 PM, li li <hannah.hlx at gmail.com> wrote:
> Dear all,
>  I have a function f(x)  which return a list as result.
>
> $T1
> [1] 0.03376190
> $T2
> [1] 0.04725
> $T3
> [1] 0.3796071
> $T4
> [1] 0.3713452
> $T5
> [1] 0.4523651
> $T6
> [1] 0.4575873
>
>  I now find the result for a vector of x values at one time. I want to
> store the reuslt
> for each xi value in a column of a matrix
>
>  x <- seq(0,1, by=0.1)
> result <- matrix(0, nrow=6, ncol=length(x))
>
> for (i in 1:length(x)){result[,i] <- f(x[i])}
>
> It is not working. Can some help me.
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list