tmp0 - list(a=1, b=2, c=3)
tmp0[b] - list(NULL) # single [, list(NULL), not double [[ and bare NULL
str(tmp0)
# List of 3
# $ a: num 1
# $ b: NULL
# $ c: num 3
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
-Original Message-
From: r-help-boun...@r-project.org
HI,
You could try these:
tmp1-list(a=1,b=NA,c=3,d=NA)
lapply(tmp1,function(x) if(is.na(x)) NULL else x) #changing NA to NULL
#$a
#[1] 1
#
#$b
#NULL
#
#$c
#[1] 3
#
#$d
#NULL
#other case;
tmp2-list(a=1,b=3,c=4,d=5) #want to change list elements a, c to NULL
tmp3-lapply(tmp2,function(x)
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)) ## list
On Fri, Feb 17, 2012 at 7:51 PM, Benilton Carvalho
beniltoncarva...@gmail.com 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,
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
beniltoncarva...@gmail.com javascript:; wrote:
Hi everyone,
For reasons beyond the scope of this message,
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
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.
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.
8 matches
Mail list logo