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

Example: Delete Names from Example Vector with unname() Function

unname(vec)         # Applying unname function in R
# 10 11 12 13 14 15

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top