I have a dataframe in R that looks similar to the following:
A B C
A X 1
A Y 3
A Z 3
A Z 2
How can I convert the single column 'C' into multiple columns that correspond to their values in B, given that all the columns contain factors and not strings or integers?
I want something that looks like below, either with or without the B/C columns still in the dataframe.
A B C X Y Z
A X 1 1 NA NA
A Y 3 NA 3 NA
A Z 3 NA NA 3
A Z 2 NA NA 2
Ideally, I would like my final output to be a dataframe in R, as I intend to merge it with another dataframe that has matching values A values.
Apologies if this post is duplicate but I didn't spot any where I could tell somebody was asking the same thing. - Thanks!