Re: [R] programming questions

2010-11-03 Thread Henrik Bengtsson
On Wed, Nov 3, 2010 at 1:04 PM, ivo welch wrote: > thanks, eric---I need a little more clarification.  *yes, I write > functions and then forget them.  so I want them to be self-sufficient. >  I want to write functions that check all their arguments for > validity.)  For example, > >  my.fn <- fun

Re: [R] programming questions

2010-11-03 Thread ivo welch
thanks, eric---I need a little more clarification. *yes, I write functions and then forget them. so I want them to be self-sufficient. I want to write functions that check all their arguments for validity.) For example, my.fn <- function( mylist ) { stop.if.not( is.defined(mylist) ) #

Re: [R] programming questions

2010-11-03 Thread David Winsemius
On Nov 3, 2010, at 3:32 PM, ivo welch wrote: thanks, barry and eric. I didn't do a good job---I did an awful job. is.defined(never.before.seen$anything) ## if a list does not exist, anything in it does not exist either Except the $ function return NULL rather than an error and you alrea

Re: [R] programming questions

2010-11-03 Thread Erik Iverson
alas, should R not come with an is.defined() function? ?exists a variable may never have been created, and this is different from a variable existing but holding a NULL. this can be the case in the global environment or in a data frame. > is.null(never.before.seen) Error: objected 'ne

Re: [R] programming questions

2010-11-03 Thread ivo welch
thanks, barry and eric. I didn't do a good job---I did an awful job. alas, should R not come with an is.defined() function? a variable may never have been created, and this is different from a variable existing but holding a NULL. this can be the case in the global environment or in a data fram

Re: [R] programming questions

2010-11-03 Thread Barry Rowlingson
On Wed, Nov 3, 2010 at 6:17 PM, ivo welch wrote: > yikes.  this is all my fault.  it was the first thing that I ever > defined when I started using R. > >   is.defined <- function(name) exists(as.character(substitute(name))) > > I presume there is something much better... You didn't do a good jo

Re: [R] programming questions

2010-11-03 Thread Jonathan P Daily
the room, the thing itself have purpose? Or do we, what's the word... imbue it." - Jubal Early, Firefly From: ivo welch To: Erik Iverson Cc: r-help Date: 11/03/2010 02:20 PM Subject: Re: [R] programming questions Sent by: r-help-boun...@r-project.org yikes. this is all my

Re: [R] programming questions

2010-11-03 Thread ivo welch
yikes. this is all my fault. it was the first thing that I ever defined when I started using R. is.defined <- function(name) exists(as.character(substitute(name))) I presume there is something much better... /iaw On Wed, Nov 3, 2010 at 2:12 PM, Erik Iverson wrote: > > > ivo welch wrote:

Re: [R] programming questions

2010-11-03 Thread Duncan Murdoch
On 03/11/2010 2:05 PM, ivo welch wrote: quick programming questions. I want to "turn on" more errors. there are two traps I occasionally fall into. * I wonder why R thinks that a variable is always defined in a data frame. > is.defined(d) [1] FALSE > d= data.frame( x=1:5,

Re: [R] programming questions

2010-11-03 Thread Erik Iverson
ivo welch wrote: quick programming questions. I want to "turn on" more errors. there are two traps I occasionally fall into. * I wonder why R thinks that a variable is always defined in a data frame. > is.defined(d) [1] FALSE > d= data.frame( x=1:5, y=1:5 ) > is.defined(

[R] programming questions

2010-11-03 Thread ivo welch
quick programming questions. I want to "turn on" more errors. there are two traps I occasionally fall into. * I wonder why R thinks that a variable is always defined in a data frame. > is.defined(d) [1] FALSE > d= data.frame( x=1:5, y=1:5 ) > is.defined(d$z) [1] TRUE