I am trying to create a new column with information from another column. For example, I want "Neutrophil_A0Late" to have "Late" in a new column, and "Neutrophil_A0Peak" to have "Peak" in the new column. My current code is:
gene_CNS <- melt(gene_CNS)
mutate(gene_CNS, timepoint = case_when(
endsWith("variable", "k") ~ "Peak",
endsWith("variable", "e") ~ "Late",
endsWith("variable", "l") ~ "Preclinical",
endsWith("variable", "t") ~ "Onset"))
and it spits out:
X1 variable value timepoint
1 Mertk Neutrophils_A0Late 0.008430985 Late
2 Mertk Neutrophils_A0Onset 0.000000000 Late
3 Mertk Neutrophils_A0Peak 0.000000000 Late
4 Mertk Neutrophils_A0Preclinical 0.000000000 Late
Clearly it thinks all of my "variable" entries end in "e", and I'm not sure why. Can anyone help? Please let me know if you need any more information.