[R] how to test the existence of a name in a dataframe
wolfram at fischer-zim.ch
Tue Dec 7 09:47:13 CET 2004
I wanted to test if there exists already a name (which is
incidentally a substring of another name) in a dataframe.
I did e.g.:
 "Fertility" "Agriculture" "Examination" "Education"
 "Catholic" "Infant.Mortality"
> ! is.null(swiss$EduX)
> ! is.null(swiss$Edu)
I did not expect to get TRUE here because ``Edu'' does not exist
as name of ``swiss''.
I did finally:
> 'Edu' %in% names(swiss)
for which I got the expected FALSE.
My question: What is the recommended way to do such a test?
Thanks - Wolfram Fischer
More information about the R-help