[R] Can a variable name include '_' or '.' in portable R code
Ben Bolker
bolker at ufl.edu
Sun Aug 16 17:06:40 CEST 2009
I think you're misinterpreting the context, although it is admittedly a
confusing context.
I think that what is meant by this that you should NOT use accented symbols
(or other symbols such as ß), which could be considered "alphanumeric". The
rest
of the sentence in which this note occurs explicitly says that _ and . are
allowed:
Normally all alphanumeric symbols are allowed1 (and in some
countries this includes
accented letters) plus ‘.’ and ‘_’, with the restriction that a name
must start with ‘.’ or a
letter, and if it starts with ‘.’ the second character must not be a
digit.
You will see various styles used in R code -- _ or . as separator, or
so-called "camel case"
(word1Word2 or Word1Word2: <http://en.wikipedia.org/wiki/CamelCase>).
There
is a reasonable argument *against* using . as a separator because names can
then
be confused with S3 methods ...
Peng Yu wrote:
>
> Hi,
>
> It says in R-intro.pdf, "For portable R code (including that to be
> used in R packages) only A–Za–z0–9 should be used." I'm an wondering
> why '_' and '.' can be used in portable R code.
>
> It very common that some variable name should be composed of two or
> more English words. Can somebody let me know what is the widely
> accepted practice to concatenate two English words into a variable
> name? For example, shall I use "word1_word2" or "Word1Word2" or
> "word1.word2"?
>
>
--
View this message in context: http://www.nabble.com/Can-a-variable-name-include-%27_%27-or-%27.%27-in-portable-R-code-tp24994043p24994409.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list