1

I'm trying to add header to the first column called "TYPE"- this is the result I get: enter image description here

this is the result I want: enter image description here

thanks

sgibb
  • 25,396
  • 3
  • 68
  • 74
  • 1
    Please produce a sample of your data: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Henk Apr 12 '14 at 15:57

3 Answers3

2

I am not sure, my answer will be useful or not. But I faced same problem and I solved this problem in following way.

library(tidyverse)

rownames_to_column(mtcars,var = "Type") -> df
df

Thanks!!...

1

I understand correctly you want to name... the row names there is no way to do this unless you get the row names and make a column of it You seem to think row names is a column

statquant
  • 13,672
  • 21
  • 91
  • 162
0
col.names(yourtable)[1] <- "Type"
Rodrigo
  • 4,706
  • 6
  • 51
  • 94
  • It will work if first column contains this names. But if this first column is attribute `rownames` then I'm afraid there is nothing we can do about it. – bartektartanus Apr 12 '14 at 16:12
  • 1
    not working... this just rename the second column... and if i try to do col.names(cars)[0] its give me error: Error in col.names(cars)[0] <- "Type" : could not find function "col.names" – user1984762 Apr 12 '14 at 16:14
  • Actually I think that the functioni is: colnames(df)[1] <- "Type" – user2097810 Apr 12 '14 at 16:15