I need some help setting up a code in R for a solving a problem:
I want to give some string data to R as input which contains several words (phrases, tweets, whatever you want). The strings could also have multiple " " or "," as seperators.
sample input data
I want R to setup a variable for each unique word within all input strings and set 1 (or TRUE, or anything else) when the string contains this specific word.
So my desired output looks something to this:
sample output
The empty spaces in the columns should contain 0, for easier reading I left them out.
To be honest I am no expert for loops and think there could be an easier solution with a package. I appreciate any support from your site on this topic, as I have several different projects where the solution could save me a lot of time.
Edit: I want to keep the original ID & String for further processing.