I have a dataframe with 4 columns. How do I give the first column a name?
I tried using dplyr
but it doesn't work.
colnames(df)[0] <- "Test"
I have a dataframe with 4 columns. How do I give the first column a name?
I tried using dplyr
but it doesn't work.
colnames(df)[0] <- "Test"
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")