-1

I have a dataframe with 4 columns. How do I give the first column a name?

enter image description here

I tried using dplyr but it doesn't work.

colnames(df)[0] <- "Test"
NelsonGon
  • 13,015
  • 7
  • 27
  • 57
Jane
  • 385
  • 4
  • 11

1 Answers1

3

That's not a column, those are the row names. Within the tidyverse there's a function to create a column out of them:

 df<-tibble::rownames_to_column(df, "test") 
iod
  • 7,412
  • 2
  • 17
  • 36