p3<-lapply(tmp2,function(x) {if(names(tmp2)[match.call()[[2]][[3]]]%in%
c("a","c")) NULL else x})
tmp3
#$a
#NULL
#
#$b
#[1] 3
#
#$c
#NULL
#
#$d
#[1] 5
A.K.
- Original Message -
From: Gonçalo Ferraz
To: r-help@r-project.org
Cc:
Sent: Thursday, November 15, 2
-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf
> Of Gonçalo Ferraz
> Sent: Thursday, November 15, 2012 1:01 PM
> To: r-help@r-project.org
> Subject: [R] assigning NULL to a list element without changing the length of
> the list
>
> Hi,
>
> I have
Hi,
I have a list:
tmp0 <- list(a=1, b=2, c=3)
And I realize that I can append a NULL element to the end of this list, just by
writing:
length(tmp0) <- 4
Now, the question is, how can I assign NULL to one of the existing list
elements without changing the length of the list?
Please note I a
Thanks guys... I'm already embarrassed given how simple the solutions are. b
On Saturday, 18 February 2012, Hadley Wickham wrote:
> On Fri, Feb 17, 2012 at 7:51 PM, Benilton Carvalho
> > wrote:
> > Hi everyone,
> >
> > For reasons beyond the scope of this message, I'd like to append a
> > NULL el
On Fri, Feb 17, 2012 at 7:51 PM, Benilton Carvalho
wrote:
> Hi everyone,
>
> For reasons beyond the scope of this message, I'd like to append a
> NULL element to the end of a list.
>
> tmp0 <- list(a=1, b=NULL, c=3)
> append(tmp0, c(d=4)) ## works as expected
> append(tmp0, c(d=NULL)) ## list with
On Sat, Feb 18, 2012 at 01:51:01AM +, Benilton Carvalho wrote:
> Hi everyone,
>
> For reasons beyond the scope of this message, I'd like to append a
> NULL element to the end of a list.
>
> tmp0 <- list(a=1, b=NULL, c=3)
> append(tmp0, c(d=4)) ## works as expected
> append(tmp0, c(d=NULL)) ##
Hi Mark,
thank you very much! This is perfect! Naive from my part not thinking of c()...
Cheers, b
__
R-help@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
Hi Benilton: David's solution is short and sweet but below also works. I
searched and searched and finally found it in the R-inferno by Patrick
Burns. I never looked at the R-inferno carefully before. After glancing at
it, I'm printing it out and binding it tomorrow. It's the
"got ya" book for R.
Thank you very much, David.
__
R-help@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.
On Feb 17, 2012, at 8:51 PM, Benilton Carvalho wrote:
tmp0 <- list(a=1, b=NULL, c=3)
> length(tmp0) <- 4
> tmp0
$a
[1] 1
$b
NULL
$c
[1] 3
[[4]]
NULL
David Winsemius, MD
West Hartford, CT
__
R-help@r-project.org mailing list
https://stat.ethz.c
Hi everyone,
For reasons beyond the scope of this message, I'd like to append a
NULL element to the end of a list.
tmp0 <- list(a=1, b=NULL, c=3)
append(tmp0, c(d=4)) ## works as expected
append(tmp0, c(d=NULL)) ## list with a/b/c only
Given that I could use
tmp0$a <- NULL
to remove 'a', I see
11 matches
Mail list logo