0

I did not see anything that completely matches my issue, so I will address it here. In my dataset (lets call it microbes) I am simply trying to switch the rows (BacteriaType) and the columns (SD1-SD4) for my data. My data look like this:

enter image description here (cannot post it directly into the message)

Just to orient you to the type of data I have, in this example, SD1/SD2/SD3/SD4 is considered participant ID. For example, for participant SD1, there are 10 types of B1, for participant SD3, there are 9 types of B3, etc.

I simply created another data frame (called trans.microbes) and used t(microbes) to transpose the data, which worked fine. So to summarize what I did so far:

trans.microbes = t(microbes)

The problem is, the above code gave me an extra row with generic variables names (V1, V2...Vn). Okay, no problem, just delete the first row using this code:

trans.microbes = trans.microbes[-1,]

However, THIS did not do anything; those generic variable names are still in the first row. How do I remove these generic variable names so that the names I created (after transposing, this would be the BacteriaType) remain? Furthermore, is there a command that I can put in the syntax for transposing to prevent the generic variable names from being created?

I know it is something simple, but I just learned R literally two months ago, so I don't know how to solve this.

Erica
  • 1
  • Please sshow a smal reproducible example using `dput` instead of imagess – akrun Dec 21 '19 at 17:41
  • 2
    Does this answer your question? [Transpose a data frame](https://stackoverflow.com/questions/6778908/transpose-a-data-frame) – ander2ed Dec 21 '19 at 18:03

0 Answers0