[Rd] assigning NULLs to elements of a list

2008-02-12 Thread Oleg Sklyar
Dear developers: I have just came across an (unexpected to me) behaviour of lists when assigning NULLs to list elements. I understand that a NULL is a valid R object, thus assigning a NULL to a list element should yield exactly the same result as assigning any other object. So I was surprised w

Re: [Rd] assigning NULLs to elements of a list

2008-02-12 Thread Thomas Lumley
On Tue, 12 Feb 2008, Oleg Sklyar wrote: > Dear developers: > > I have just came across an (unexpected to me) behaviour of lists when > assigning NULLs to list elements. I understand that a NULL is a valid R > object, thus assigning a NULL to a list element should yield exactly the > same result as

Re: [Rd] assigning NULLs to elements of a list

2008-02-12 Thread Jeffrey J. Hallman
>From your tone, I gather you don't much like this behavior, and I can see your point, as it not very intuitive that setting a list element to NULL deletes any existing element at that index. But is there a better way to delete an element from a list? Maybe there should be. Jeff Prof Brian Rip

Re: [Rd] assigning NULLs to elements of a list

2008-02-12 Thread Stephen B. Weston
Oleg Sklyar wrote: > Dear developers: > > I have just came across an (unexpected to me) behaviour of lists when > assigning NULLs to list elements. I understand that a NULL is a valid R > object, thus assigning a NULL to a list element should yield exactly the > same result as assigning any oth

Re: [Rd] assigning NULLs to elements of a list

2008-02-12 Thread Prof Brian Ripley
On Tue, 12 Feb 2008, Oleg Sklyar wrote: > Dear developers: > > I have just came across an (unexpected to me) behaviour of lists when > assigning NULLs to list elements. I understand that a NULL is a valid R > object, thus assigning a NULL to a list element should yield exactly the > same result as

Re: [Rd] assigning NULLs to elements of a list

2008-02-12 Thread Dan Davison
On Tue, Feb 12, 2008 at 11:06:59AM +, Oleg Sklyar wrote: > Dear developers: > > I have just came across an (unexpected to me) behaviour of lists when > assigning NULLs to list elements. I understand that a NULL is a valid R > object, thus assigning a NULL to a list element should yield exact

Re: [Rd] assigning NULLs to elements of a list

2008-02-13 Thread Oleg Sklyar
:) Well, yes, but what do you do with a named vector if you want to remove an element by name? It is not general: you cannot do that on vectors, matrices, arrays and all inherited objects anyway. Using a negative index is a standard and throughout practice of deleting elements in R. Surely one

Re: [Rd] assigning NULLs to elements of a list

2008-02-13 Thread Gabor Grothendieck
But what about by name? a <- list(a = 1, b = 2, c = 3) a$b <- NULL On Feb 13, 2008 9:39 AM, Oleg Sklyar <[EMAIL PROTECTED]> wrote: > Hmm, I think the pretty traditional R style does the job... > > a = list(1,2,3) > a[-2] > > So I really do not see a good reason for doing a[2] = NULL instead of

Re: [Rd] assigning NULLs to elements of a list

2008-02-13 Thread Oleg Sklyar
Hmm, I think the pretty traditional R style does the job... a = list(1,2,3) a[-2] So I really do not see a good reason for doing a[2] = NULL instead of a = a[-2] Jeffrey J. Hallman wrote: >>From your tone, I gather you don't much like this behavior, and I can see your > point, as it not very in