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

Gabor Grothendieck ggrothendieck at gmail.com
Thu Jan 14 02:24:23 CET 2010


See ?rep where it says that the argument must be a vector.  Try
   rep(list(sin), 3)

On Wed, Jan 13, 2010 at 8:11 PM, Matthew Walker
<matthew.walker.1 at ulaval.ca> wrote:
> 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
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list