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.:
data(swiss)
names(swiss)
[1] FertilityAgriculture Examination Education
[5] Catholic Infant.Mortality
! is.null(swiss$EduX)
[1]
Hi Wolfram,
this behaviour is due to partial matching. Observe that
data(swiss)
swiss$Ed
swiss$Edu
swiss$Educ
I think the best way to do it is with `%in%' or `match()', i.e.,
c(Ed, Edu, Educ, Education) %in% names(swiss)
I hope it helps.
Best,
Dimitris
Dimitris Rizopoulos
Ph.D. Student