Ng Stanley
2008-Apr-14 13:47 UTC
[R] Initialize many variables to NUL, check whether an object exist
Hi, Two questions: A) I need to initialize many variables to NULL. So I created variable_names <- c("a1", "a2"). What can I do to variable_names so that variable a1 is NULL and a2 is NULL ? B) How can I check whether an object exist ? Thanks Stanley [[alternative HTML version deleted]]
Gabor Csardi
2008-Apr-14 13:53 UTC
[R] Initialize many variables to NUL, check whether an object exist
On Mon, Apr 14, 2008 at 09:47:49PM +0800, Ng Stanley wrote:> Hi, > > Two questions: > > A) I need to initialize many variables to NULL. So I created variable_names > <- c("a1", "a2"). What can I do to variable_names so that variable a1 is > NULL and a2 is NULL ?for (n in variable_names) assign(n, NULL)> B) How can I check whether an object exist ?help.search("exists") G.> Thanks > Stanley > > [[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.-- Csardi Gabor <csardi at rmki.kfki.hu> UNIL DGM