+4 votes
in Programming Languages by (6.5k points)
I want to delete the header from the data frame. What R function should I use for it?

1 Answer

0 votes
by (35.8k points)

The names() function of R can be used to remove the header/column names from a data frame.

Here is an example:

> df <- data.frame("A"= 1:5, "B"=11:15, "C"=21:25, "D"=31:35)
> df
  A  B  C  D
1 1 11 21 31
2 2 12 22 32
3 3 13 23 33
4 4 14 24 34
5 5 15 25 35
> names(df) <- NULL
> df
            
1 1 11 21 31
2 2 12 22 32
3 3 13 23 33
4 4 14 24 34
5 5 15 25 35

Related questions

+4 votes
1 answer
+2 votes
1 answer
+2 votes
1 answer
...