\HeaderA{make.names}{Make Syntactically Valid Names}{make.names}
\keyword{character}{make.names}
\begin{Description}\relax
Make syntactically valid names out of character vectors.
\end{Description}
\begin{Usage}
\begin{verbatim}
make.names(names, unique = FALSE, allow_ = TRUE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{names}] character vector to be coerced to syntactically valid
names. This is coerced to character if necessary.
\item[\code{unique}] logical; if \code{TRUE}, the resulting elements are
unique.  This may be desired for, e.g., column names.
\item[\code{allow\_}] logical.  For compatibility with \R{} prior to 1.9.0.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
A syntactically valid name consists of letters, numbers and the dot or
underline characters and starts with a letter or the dot not followed
by a number.  Names such as \code{".2way"} are not valid, and neither
are the \LinkA{reserved}{reserved} words.

The definition of a \emph{letter} depends on the current locale, but
only ASCII digits are considered to be digits.

The character \code{"X"} is prepended if necessary.
All invalid characters are translated to \code{"."}.  A missing value
is translated to \code{"NA"}.  Names which match \R{} keywords have a dot
appended to them.  Duplicated values are altered by
\code{\LinkA{make.unique}{make.unique}}.
\end{Details}
\begin{Value}
A character vector of same length as \code{names} with each changed to
a syntactically valid name, in the current locale's encoding.
\end{Value}
\begin{Note}\relax
Prior to \R{} version 1.9.0, underscores were not valid in variable names,
and code that relies on them being converted to dots will no longer
work. Use \code{allow\_ = FALSE} for back-compatibility.

\code{allow\_ = FALSE} is also useful when creating names for export to
applications which do not allow underline in names (for example,
S-PLUS and some DBMSs).
\end{Note}
\begin{SeeAlso}\relax
\code{\LinkA{make.unique}{make.unique}},
\code{\LinkA{names}{names}},
\code{\LinkA{character}{character}},
\code{\LinkA{data.frame}{data.frame}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
make.names(c("a and b", "a-and-b"), unique=TRUE)
# "a.and.b"  "a.and.b.1"
make.names(c("a and b", "a_and_b"), unique=TRUE)
# "a.and.b"  "a_and_b"
make.names(c("a and b", "a_and_b"), unique=TRUE, allow_=FALSE)
# "a.and.b"  "a.and.b.1"

state.name[make.names(state.name) != state.name] # those 10 with a space
\end{ExampleCode}
\end{Examples}

