[R] Error: object of type 'closure' is not subsettable

Matthew Walker matthew.walker.1 at ulaval.ca
Thu Jan 14 02:11:47 CET 2010


Hi everyone,

Would somebody please explain (or point me to a reference that explains) 
the following error:

"Error: object of type 'closure' is not subsettable"

I was trying to use rep() to replicate a function:

 > example_function <- function() { return(TRUE) }
 > rep(example_function, 3)
Error: object of type 'closure' is not subsettable

But I just cannot understand this error.  I can combine functions using 
"c" without any problems:

 > c(example_function, example_function)
[[1]]
function ()
{
    return(TRUE)
}

[[2]]
function ()
{
    return(TRUE)
}

What am I doing wrong when I use rep()?

Thanks in advance,

Matthew Walker



More information about the R-help mailing list