I think it'd be more appropriate to use: sapply(a, "==", "NULL")
or sapply(a, "==", "NA") for this case. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://www.med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Seth Falcon" <[EMAIL PROTECTED]> To: <r-devel@stat.math.ethz.ch> Sent: Tuesday, March 07, 2006 4:37 PM Subject: Re: [Rd] possible bug: NULL equality in lists. > Uwe Ligges <[EMAIL PROTECTED]> writes: > >> Charles Dupont wrote: >> >>> I was messing around with R and I found an example R behaving >>> oddly: >>> >>> a <- alist(NULL, "bob", c(3,6,2,3)) >>> a >>> a == 'NULL' >>> a == "NULL" >>> a == 'cat' >>> >> >> >> Always use is.null() to test on NULL, as in: > > What should I do if I want to check for the string "NULL"? > >> a <- list(NULL, "NULL", NA, "NA") > >> a == "NULL" > [1] TRUE TRUE FALSE FALSE > >> a == "NA" > [1] FALSE FALSE TRUE TRUE > > These are because of as.character: > >> as.character(a) > [1] "NULL" "NULL" "NA" "NA" > > Yet, > >> as.character(NULL) > character(0) >> as.character(NA) > [1] NA > > > > + seth > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel