Re: [R] Initialize many variables to NUL, check whether an object exist

From: Ng Stanley <stanleyngkl_at_gmail.com>
Date: Tue, 15 Apr 2008 00:06:14 +0800

Hi,

How can I force the assignment ?

> RG[["ABC"]] <- c("a", "b")

Error in RG[["ABC"]] <- c("a", "b") :
  more elements supplied than there are to replace

On Mon, Apr 14, 2008 at 9:53 PM, Gabor Csardi <csardi_at_rmki.kfki.hu> wrote:

> 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<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
>

        [[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. Received on Mon 14 Apr 2008 - 16:10:49 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 14 Apr 2008 - 20:31:37 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive