How should I use 'agrep' function in a loop to count the 'number of mentions' in the reviews about attraction_name?
Dataset_1 has 10k reviews and Dataset_2 has 90 attraction_names.
Dataset_1$review_text <- c("I like park_1 compared to park_2", "Park_3 is highly recommended")
Dataset_2$attraction_name <- c("park_1","park_2","park_3")
Ideally, I want to have a column in Dataset_1 which shows how many times attractions are mentioned in total for each review. For example, in the case above, the first review will have a count of 2.
Thanks in advance for your reply.
For now, I have something like below.
`# Go through every review and see how many approximate matches there are for each review
#Create empty list for the results of loop.
rides <- ride_data$name
#This loop counts the approximate matches
for (i in 1:length(rides)) {
dataset <- disney_data$Review_Text
ride_to_search <- rides[i]
result[[i]] <- length(test <-agrep(ride_to_search,dataset,value=T))
i = i+1
}`