R How to Remove Names from Named Numeric Vector (Example Code)
In this tutorial you’ll learn how to delete names from a named vector in the R programming language.
Example Data
vec <- 10:15 # Create example vector names(vec) <- paste0("Name_", 1:6) vec # Print example vector # Name_1 Name_2 Name_3 Name_4 Name_5 Name_6 # 10 11 12 13 14 15 |
vec <- 10:15 # Create example vector names(vec) <- paste0("Name_", 1:6) vec # Print example vector # Name_1 Name_2 Name_3 Name_4 Name_5 Name_6 # 10 11 12 13 14 15
Example: Delete Names from Example Vector with unname() Function
unname(vec) # Applying unname function in R # 10 11 12 13 14 15 |
unname(vec) # Applying unname function in R # 10 11 12 13 14 15