0

The original dataframe I have doesn't specify what those values are. Now I want to add a extra on top and add category to each column like below:

Original has only two row and no category names:

blank blank
1 34
2 22

I want to transform it like this:

Habitat Count of birds
1 34
2 22

How do I do this?

I found several functions on Google, but the don't really match with my needs.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Spybuster
  • 19
  • 5
  • You may need to rename the columns i.e. `names(df1) <- c("Habitat", "Count of birds")`. If it is a csv file. read the data with `read.csv` and `header = FALSE` which returns by adding default names or specify it in `col.names` as the desired column names i.e. `df1 <- read.csv("file.csv", header = FALSE, col.names = c("Habitat", "Count of birds"))` – akrun Oct 27 '22 at 17:41

0 Answers0