[R] Remove all spaces from a string so it can be used by assign()
Jason Rupert
jasonkrupert at yahoo.com
Sat Jul 4 05:19:10 CEST 2009
Don't think you can have numerics as the first characters in a variable name.
R ninjas can confirm, but I think you will be able to have numerics after an initial alpha character, e.g.
Fe56 is ok, but 56Fe is not ok.
Also, check out "gsub". This is a really powerful string editing tool.
Hope this helps.
>
> > -----Original Message-----
> > From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-
> > project.org] On Behalf Of Kurt Smith
> > Sent: Friday, July 03, 2009 4:57 AM
> > To: r-help at r-project.org
> > Subject: [R] Remove all spaces from a string so it can
> be used by
> > assign()
> >
> >
> > Hi
> >
> > I have a string "56 Fe [1]" that I would like to use
> as a variable name
> > by using "assign" however I think the spaces and
> brackets might be
> > causing R some trouble.
> >
> > How can I change the string so that it just becomes
> 56Fe1 and can be
> > used as a variable name.
> >
> >
> > Thank You
> >
> > Kurt
> >
> >
> _________________________________________________________________
> >
> > [[elided Hotmail spam]]
> >
> >
> > [[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.
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list