I have a data frame which has one colomn, a list of words. I'd like to extract the charcters from each word and have it stored as a position colomn in the data frame. For example, if the dataframe is defined like this:
words <- c('which', 'there', 'their', 'would')
words <- as.data.frame(words)
I'd like it to look like this at the end:
| words | first_pos | second_pos | third_pos | fourth_pos | fifth_pos |
|---|---|---|---|---|---|
| which | w | h | i | c | h |
| there | t | h | e | r | e |
| their | t | h | e | i | r |
| would | w | o | u | l | d |
What I have so far is:
position <- c("first_pos", "second_pos", "third_pos", "fourth_pos", "fifth_pos")
words[position] <- NA
dismantled <- str_split(words$words,"")
This dismantles the words and creates the colomns I need. However, I could use some help filling the rows of the colomns with the letters.