How to Display & Remove NA in Frequency Table in R (2 Examples)

In this article you’ll learn how to remove or display NA values in a frequency table in R.

Creation of Example Data

my_data <- c(LETTERS[1:5], NA)    # Example vector in R
my_data                           # Display example vector in RStudio console
# [1] "A" "B" "C" "D" "E" NA

Example 1: Do Not Show NA Values in Frequency Table

table(my_data)                    # Remove NA values from table
# my_data
# A B C D E 
# 1 1 1 1 1

Example 2: Do Show NA Values in Frequency Table

table(my_data,                    # Show NA values in table
      useNA = "always")
# my_data
#    A    B    C    D    E <NA> 
#    1    1    1    1    1    1

Related Tutorials & Further Resources

Have a look at the following R tutorials. They discuss similar topics as this page.

Leave a Reply

Your email address will not be published.

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