How can I edit my table so that all the values for each sample appear in 1 row for the sample?

16 views Asked by At

I currently have a table that looks like this:

Sample Name A A A A A A A A B B B B B B B B C C C C C C C C D D ...

Assay Name: 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8...

Concentration: # # # # # # # # # #....

I want it to ideally look like this:

1 2 3 4 5 6 7 8

A # # # # # # # #

B # # # # # # # #

C # # # # # # # #

D # # # # # # # # ...

Is there a way to do this in R? I want to be able to only have 1 row for each sample name and have 8 columns for each of the assays, and the values for each cell will be the concentration of that assayed molecule for each sample. Thank you!

I tried using pivot_longer but I am a beginner at R and I cannot figure out how to make the assay names into the column names.

0

There are 0 answers