I know my question is simple but I've trying all morning and I can't get my head around it.
I have this data frame:
GeneID Gene.Symbol01 Ratio.2h Ratio.6h Ratio.10h Ratio.24h Pvalue_2h
1 174 FUT -0.23618761 -0.3276162 -0.1366940 -4.4899131 0.49045105
Pvalue_6h Pvalue_10h Pvalue_24h
1 0.06128851 0.59995612 0.0001798584
And I need to pivot_longer all columns except GeneID and GeneSymbol. The resulting data frame should have 3 new columns. One with time: 2h, 6h, 10h, and 24h. Then two more columns with the ratio values and another one with the pvalues.
I know this should be done with a combinametion of names_to and names_pattern. I have tried many things but I can't get it.
Last thing I have tried was this:
pivot_longer(cols = -c(GeneID, Gene.Symbol01),
names_to = c("Time", ".value"),
names_pattern = "_")
Dput:
structure(list(GeneID = 174, Gene.Symbol01 = "FUT", Ratio.2h = -0.23618761,
Ratio.6h = -0.3276162, Ratio.10h = -0.136694, Ratio.24h = -4.4899131,
Pvalue_2h = 0.49045105, Pvalue_6h = 0.06128851, Pvalue_10h = 0.59995612,
Pvalue_24h = 0.0001798584), row.names = c(NA, -1L), class = c("tbl_df",
"tbl", "data.frame"))