[R] Putting a NULL in a list (as cannot pass NA to C++)

From: Rees, David <david.rees_at_citi.com>
Date: Mon, 3 Dec 2007 18:41:06 -0000


Hi,

If I do the following I can have a NULL in a list

> x <- list( 1, list(3,NULL,4), 5 )
> x
[[1]]
[1] 1

[[2]]
[[2]][[1]]
[1] 3

[[2]][[2]]

NULL
[[2]][[3]]
[1] 4

[[3]]
[1] 5

This is a good thing for me as it can be passed through into C++ where I can know the value is missing. (Can't seem to detect a NA from C++ for some reason. There is RF_isNull in the API but no RF_isNA that I can find!)

Is it possible to put a null in an already created list. e.g. now do

> x[[2]][[2]] <- NULL
> x
[[1]]
[1] 1

[[2]]
[[2]][[1]]
[1] 3

[[2]][[2]]
[1] 4

[[3]]
[1] 5

But x[[2]][[2]] has been deleted.

Many thanks

Regards,
David



R-help_at_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. Received on Mon 03 Dec 2007 - 18:45:47 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 03 Dec 2007 - 21:30:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.