The setNames()
function is made for this purpose. As described in Advanced R and ?setNames
:
test <- setNames(c(1, 2), c("A", "B"))
More Related Contents:
- How to change formats of multiple variables in one dataset?
- Filtering a data frame on a vector [duplicate]
- Replace / translate characters in a string
- using Unicode ‘dingbat-like’ glyphs in R graphics, across devices & platforms, especially PDF
- Programming with dplyr using string as input
- Select subset of columns in data.table R [duplicate]
- Addressing x and y in aes by variable number
- How to rename a single column in a data.frame?
- how to read data in utf-8 format in R?
- Dynamically build call for lookup multiple columns
- Center x and y axis with ggplot2
- Categorize numeric variable with mutate
- Exact number of bins in Histogram in R
- Which is the best method to apply a script repetitively to n .csv files in R?
- Split a string by any number of spaces
- Use rle to group by runs when using dplyr
- Outputting multiple lines of text with renderText() in R shiny
- dplyr: lead() and lag() wrong when used with group_by()
- Imported a csv-dataset to R but the values becomes factors
- Why (or when) is Rscript (or littler) better than R CMD BATCH?
- How do I tell the R interpreter how to use the proxy server?
- Replace -inf, NaN and NA values with zero in a dataset in R
- Specifying formula in R with glm without explicit declaration of each covariate
- How to cross-paste all combinations of two vectors (each-to-each)?
- how do you order Months in ggplot
- Run a custom function on a data frame in R, by group
- The perils of aligning plots in ggplot
- How to create a new variable in a data.frame based on a condition?
- Understanding element wise clearing of R’s workspace
- What does the %% operator mean in R? [closed]