Matthew Walker
2010-Jan-14 01:11 UTC
[R] Error: object of type 'closure' is not subsettable
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
Gabor Grothendieck
2010-Jan-14 01:24 UTC
[R] Error: object of type 'closure' is not subsettable
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. >
Apparently Analagous Threads
- Object of type 'closure' not subsettable
- Error message: object of type 'closure' is not subsettable
- error: object of type 'closure' is not subsettable
- Sweave and " object of type 'closure' is not subsettable" error
- Problem in Starting R Server - object of type 'closure' is not subsettable