Data I'm scrapping off of the web uses the * character to denote one thing and + to denote another.
Here's an example of what it looks like:
# Original Data
original_df <- data.frame(c("Randy Watson*+", "Cleo McDowell*", "Darryl Jenks"))
names(original_df) <- 'nameinfo'
original_df
I want to transform the data to look like this output:
# What I want the Data to look like
name <- c("Randy Watson", "Cleo McDowell", "Darryl Jenks")
this_thing <- c("1", "1", "0")
that_thing <- c("1", "0", "0")
desired_df <- data.frame(name_column, this_thing, that_thing)
desired_df
I basically want to use the prsense of * to denote one flag variable, + for another variable, then remove either * or + from the nameinfo field and use it as a new variable name.
Thanks.
needleInHaystackfunction here. Usage would beneedleInHaystack(c("*", "+"), original_df$nameinfo). Some cleanup would be required.