I have a df:
Name Letter
1 A;B;C;D;E
2 A;B;C;
3 A;
4 A;B;C;D;E
I use the following code to make a df where each Letter is split into it's own column using:
library(reshape2)
new_df = transform(df, taxa = colsplit(Letter, split = ";", names = c("A", "B", "C", "D", "E")))
When I do this I get a new df that looks like:
Name .A .B .C .D .E
1 A B C D E
2 A B C C C
3 A A A A A
4 A B C D E
How do I make it so that missing letters aren't replaced by previous letter, but by a specific designator like "unclassified" so
Name .A .B .C .D .E
2 A B C C C
becomes:
Name .A .B .C .D .E
2 A B C unclass unclass