Hi, I have a vector who contents should look like this, "c" "d" NULL "e" "f" etc or 4 5 6 NULL 7 8 9 how can I represent the null value? [[alternative HTML version deleted]]
Perhaps you mean NA rather than NULL. If NA is not what you want, then I think you'll need to explain your application. On 06/09/2010 06:00, rajeshj at cse.iitm.ac.in wrote:> > Hi, > > I have a vector who contents should look like this, > > "c" "d" NULL "e" "f" etc > or > 4 5 6 NULL 7 8 9 > > how can I represent the null value? > [[alternative HTML version deleted]] > > ______________________________________________ > 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. >-- Patrick Burns pburns at pburns.seanet.com http://www.burns-stat.com (home of 'Some hints for the R beginner' and 'The R Inferno')
On 09/06/2010 03:00 PM, rajeshj at cse.iitm.ac.in wrote:> > Hi, > > I have a vector who contents should look like this, > > "c" "d" NULL "e" "f" etc > or > 4 5 6 NULL 7 8 9 > > how can I represent the null value?Hi rajesh, For character vectors, "" will probably suffice, but for numbers, you are probably stuck with NA. Jim
On 06/09/2010 1:00 AM, rajeshj at cse.iitm.ac.in wrote:> Hi, > > I have a vector who contents should look like this, > > "c" "d" NULL "e" "f" etc > or > 4 5 6 NULL 7 8 9 > > how can I represent the null value?As others have said, you probably want NA rather than NULL. If you really want NULL, then use a list (a generic vector). So x <- list("c", "d", NULL, "e", "f") y <- list(4,5,6,NULL, 7,8,9) You need to be careful when setting values, because y[[1]] <- NULL will *remove* element 1, not set it to NULL. To set it to NULL, use y[1] <- list(NULL) Duncan Murdoch