I have data that looks like this:
Set of 10 character variables
Char<-c("A","B","C","D","E","F","G","H","I","J")
And a data frame that looks like
Col1<-seq(1:25)
Col2<-c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5)
DF<-data.frame(Col1,Col2)
What I would like to do is add a third column to the data frame with logic 1 = A, 2 = B, 3 = C, etc. So the end result will be
Col3<-c("A","A","A","A","A","B","B","B","B","B","C","C","C","C","C","D","D","D","D","D","E","E","E","E","E")
DF<-data.frame(Col1,Col2,Col3)
For this simple example, I could go with a simple replacement similar to this question:
Create a new column based on 4 values in another column
But my actual dataset is much larger with a lot more variables than this simple example, so writing equivalents as in the answer above is not an option.
, . , -, Col2 Char.
1=Char[1] 2=Char[2] 3=Char[3]...... for the entire length of Col2
,