Populate columns based on letters in each position of a string in another column
I have individuals (birds) who are identified via a 3-letter system, e.g. BBO, BOB, PPG, PGP, etc. The order in the code corresponds to the position on the individual, e.g. BOB has Blue on its head, Orange on its cheek, and Blue on its neck. I want to create a data frame that takes the individual ID code and populates "head", "cheek", and "neck" columns with the colors like below: bird <- c("BOB", "OOP", "GBG") head <- c("blue", "orange", "green") cheek <- c("orange", "orange", "blue") neck <- c("blue", "purple", "green") power <- c(1, 2, 3) data <- data.frame(ID = bird, Head = head, Cheek = c
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.