[R] function return output

Uwe Ligges ligges at statistik.tu-dortmund.de
Fri Jan 16 12:06:55 CET 2009



threshold wrote:
> Hi, I wrote the function which outputs a matrix 'c' and a single value 'd',
> as follows (simplified example):
> procedure <- function(a,b){
> ...
> list(c,d)
> }
> now I want to use 'c' and 'd' in code as follows:
> d <- matrix(0,1,1)
> value <- procedure(a,b)
> and d[1,1] <- value[2] breaks telling that:
> Error in d[1, 1] : incorrect number of dimensions
> What I did wrong??, best, robert

Probably "value" is a list, hence value[2] is also a list and you cannot 
assign a list to an element of a *numeric* matrix. I guess you want 
value[[2]].
Anyway, it is all a guess since we do not know what your "procedure()" 
returns ....


Uwe Ligges




> 
> 
>




More information about the R-help mailing list