R Return Only Value of Table Element without Index & Name (Example Code)

In this tutorial, I’ll explain how to extract only values without names or indices in R programming.

Creating Example Data

data(iris)                                # Loading iris data set
iris_table <- table(iris$Sepal.Length)    # Table of Sepal.Length
iris_table                                # Showing example table
# 
# 4.3 4.4 4.5 4.6 4.7 4.8 4.9   5 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9   6 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9   7 7.1 7.2 7.3 
#   1   3   1   4   2   5   6  10   9   4   1   6   7   6   8   7   3   6   6   4   9   7   5   2   8   3   4   1   1   3   1 
# 7.4 7.6 7.7 7.9 
#   1   1   4   1

Example: Returning Element of Data Table without Name and Index

iris_table[5]                             # Get table element with name
# 4.7 
#   2
iris_table[[5]]                           # Get table element without name
# [1] 2

Further Resources

You may find some related R tutorials on topics such as data inspection, variables, and missing data below:

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