Don’t Display Data Frame Row Names in R (Example)


In this tutorial, I’ll show how to remove row names from the RStudio console output of a data frame in R programming.

The table of content is structured as follows:

Let’s start right away…


Creation of Example Data

The following data will be used as basement for this R programming tutorial:

data <- data.frame(x1 = 5:1,      # Create example data
                   x2 = 77,
                   x3 = letters[3:7])
data                              # Print example data with row names
#   x1 x2 x3
# 1  5 77  c
# 2  4 77  d
# 3  3 77  e
# 4  2 77  f
# 5  1 77  g

The previous output of the RStudio console shows the structure of our example data – It has five rows and three columns.

By default, our data frame is shown with row names when we print it to the RStudio console. Those row names are ranging from 1 to the number of rows of our example data.


Example: Don’t Display Row Names when Printing Data Frame Using print() Function

In this example, I’ll explain how to avoid printing row names of a data frame to the RStudio console.

For this, we can apply the print function and the row.names argument within the print function:

print(data, row.names = FALSE)    # Applying print() function
# x1 x2 x3
#  5 77  c
#  4 77  d
#  3 77  e
#  2 77  f
#  1 77  g

Have a look at the previous output of the RStudio console: It shows our data frame without row names.


Video, Further Resources & Summary

Do you need further info on the R programming codes of this tutorial? Then you may want to have a look at the following video of my YouTube channel. I’m explaining the R syntax of this article in the video instruction:


Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube Content Consent Button Thumbnail

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.


Furthermore, you may want to have a look at some of the related tutorials of my homepage. Some related articles on topics such as merging and data conversion are shown below.


Summary: You learned in this post how to avoid row names when printing data frames to the RStudio console in the R programming language. Let me know in the comments section, in case you have further questions and/or comments.


Subscribe to the Statistics Globe Newsletter

Get regular updates on the latest tutorials, offers & news at Statistics Globe.
I hate spam & you may opt out anytime: Privacy Policy.

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.