Uli Kleinwechter a écrit :


data[,grep("x",names(data))][is.na(data[,grep("x",names(data))])]<-0


thanks a lot. I'm just afraid that grep matches any occurence of "x" in
the variable name. So variables which would contain "x" at any position,
not necessarily only at the last one would be selected, as well. To
refine my example (sorry for having been so imprecise before...):

Replacing "x" with "x$" in grep calls should do the job...

Olivier.

______________________________________________
R-help@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.

Reply via email to