Displaying 2 results from an estimated 2 matches for "null_003f".
2009 Dec 11
1
The correct way to set an element in a list to NULL? (FAQ is not clear)
http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-set-components-of-a-list-to-NULL_003f
The explanation on this FAQ entry is not clear. It says '... similarly
for named components...'. What I understood was x[i]<-list(NULL) is
the same as x$a_name<-list(NULL). But, they are not. As the example
below shows, x$a_name<-list(NULL) is the same as x[[i]]<-list(NULL).
&...
2009 Dec 11
1
How to get rid of NULL in the result of apply()?
The following code returns a list with the 2nd element as NULL. I'm
wondering what the best way to get rid of NULL element in an
'apply()'s result.
> lapply(1:3, function(x) {
+ if(x==2) {
+ return(NULL)
+ } else {
+ return(x)
+ }
+ }
+ )
[[1]]
[1] 1
[[2]]
NULL
[[3]]
[1] 3