[R] objects inside curly braces

Duncan Murdoch dmurdoch at pair.com
Wed Nov 5 02:48:44 CET 2003


On Tue, 4 Nov 2003 16:19:44 -0800 , you wrote:

>Hello,
> 
>I am running a program in r that calls a function, which calls another
>function, which calls another etc. These functions are of the form:
> 
>example<- function(x,y,z)
> 
>{x, y, and z are defined within curly braces like this}
> 
>Here's my question. To start the main function, I input as an initial
>parameter a matrix of regressors of the form:
> 
>MyMatrix<-cbind(this.one,that.one)
> 
>That's all fine, but then I get a nonconformability message telling me that
>MyMatrix is not conformable with x. 
> 
>I can check the dimensions of MyMatrix, but x is in curly braces, and so is
>not an object. I'd like to check the dimensions of x, but can't, so it's
>hard to tell what's wrong with it.
> 
>Any suggestions?

The objects within the braces are called local variables; in most
cases they exist only for the life of the function call.

To debug them, use debug().  For example, if the function that's not
working is called foo, then do this:

debug(foo)
foo(x, y, z)

This will let you single step through the code in foo, and see what's
going on.  See ?debug for details.

Duncan Murdoch




More information about the R-help mailing list