% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/to_pinyin.R
\name{to_varname}
\alias{to_varname}
\title{Generate Valid R Variable Names from Chinese Text}
\usage{
to_varname(
  x,
  unique = TRUE,
  abbrev = NULL,
  polyphone = FALSE,
  other_replace = NULL
)
}
\arguments{
\item{x}{A character vector.}

\item{unique}{If \code{TRUE} (default), appends \code{.1}, \code{.2}, etc. to duplicates
via \code{\link[=make.names]{make.names()}}.}

\item{abbrev}{If not \code{NULL}, an integer giving the maximum length of each
syllable (e.g. \code{abbrev = 4} truncates \code{zhong} to \code{zhon}).}

\item{polyphone}{If \code{FALSE} (default), each character is converted
independently using its most common reading. If \code{TRUE}, a built-in phrase
table is used to resolve common polyphones via greedy longest-match
segmentation.}

\item{other_replace}{How to handle non-Chinese characters. \code{NULL} means
leave them as-is. A single character string replaces them.}
}
\value{
A character vector of valid R variable names.
}
\description{
Useful when cleaning imported data (e.g. from SAS or Excel) where column
labels are in Chinese.
}
\examples{
to_varname(c("\u59d3\u540d", "\u5e74\u9f84", "\u6027\u522b"))
to_varname("\u4e2d\u534e\u4eba\u6c11\u5171\u548c\u56fd", abbrev = 4)
}
