1

I am trying to add a column name to a column that doesn't already have a name. I would be fine with even deleting the column, I just don't know how to select a column without a name. Here is a small example. I would be trying to rename that first column or even delete it. For whatever reason, I think dplyr add that column when I manipulate my data. It could even be tidyr. I'm not sure which package is adding that column, but it is annoying.

The first column doesn't have a name. What I want to do is either give it a name or delete it because it gives me issues when I save the data as a text file.

 chr location effect impact
1 4 345765 missense moderate
2 7 6543 frameshift high
3 8 864523 missense moderate
neuron
  • 1,949
  • 1
  • 15
  • 30
  • 7
    are you sure you're not looking at the row names of the data frame? these are printed by default. Can you show us `str(your_data)` ? (what is `names(your_data)`? `ncol(your_data)` ? – Ben Bolker Jun 28 '18 at 12:41
  • You can delete a column also by its position, for example: `your_data = your_data[,-3]`. – Benjamin Schlegel Jun 28 '18 at 12:51
  • try `write.table(df, "test.txt", row.names = F)` while writing your final data in a text file. – Prem Jun 28 '18 at 13:10

1 Answers1

0

This Question is not clear, but you can change the name of the first (or any) column using the index of the column like this:

colnames(data.frame)[1] <-  "Brian"
Majid
  • 1,836
  • 9
  • 19