With the following data frame:
Query
1 word1 word2 word3
2 word4 word5
3 word6
4 word7 word8
df1 <- read.table(header = TRUE, text = "Query
1 'word1 word2 word3'
2 'word4 word5'
3 word6
4 'word7 word8'")
I want create a new data frame with the following format:
Query
1 word1
2 word2
3 word3
4 word4
5 word5
6 word6
7 word7
8 word8
Do you know of a R function or a R package able to do it? I am actually using the function word from stringr's package, but it seems to only being splitting the first word of every observation. For getting all words, I should have to calculate every row's bond (1, total number of words <- whitespaces + 1) and call the function within a "for" for every row, which is not optimal as my dataframe have more than 5M observations.