0

What is the best way to turn a data set with the first column being the headers and the data being in rows versus columns? How do I convert them to columns? I have transposed the data and then converted the first row to column headers but the class of my data changed.

  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Feb 06 '20 at 19:20
  • True...was in a hurry and didn't have time to include the code. – KaiserRoll Feb 06 '20 at 19:47

1 Answers1

0

Please see this answer:

tmydf = setNames(data.frame(t(mydf[,-1])), mydf[,1])

The source is from a thread with the exact same issue you're having here.

Transposing a dataframe maintaining the first column as heading

Tim
  • 105
  • 7