Write Data Frame without Header in R (Example)
In this tutorial, I’ll show how to export a data frame without column names in R.
Table of contents:
With that, let’s get started…
Creation of Exemplifying Data
Consider the following example data:
data <- data.frame(x1 = 9:4, # Create data frame x2 = letters[10:15], x3 = 9) data # Print data frame to RStudio console # x1 x2 x3 # 1 9 j 9 # 2 8 k 9 # 3 7 l 9 # 4 6 m 9 # 5 5 n 9 # 6 4 o 9
Have a look at the previous output of the RStudio console. It shows that our example data has six rows and three columns. The variables of our data frame are called x1, x2, and x3.
Example: Exporting CSV File without Header Using write.table Function & col.names Argument
In this example, I’ll illustrate how to write a CSV file without column names.
For this, we have to use the write.table function. Within the write.table function, we have to specify the col.names argument to be equal to FALSE:
write.table(data, # Write CSV file without header "data.csv", sep = ";", col.names = FALSE)
After running the previous R code, you should find a new CSV file called “data” in your working directory that looks like follows:
Video, Further Resources & Summary
In case you need further information on the contents of this tutorial, you could have a look at the following video which I have published on my YouTube channel. In the video, I illustrate the R programming codes of this tutorial.
The YouTube video will be added soon.
In addition, you may want to have a look at the related R tutorials on this homepage. You can find some tutorials about exporting data below.
This post explained how to write a data frame without header in the R programming language. Don’t hesitate to let me know in the comments section below, if you have additional questions. Furthermore, please subscribe to my email newsletter in order to receive updates on the newest tutorials.