I'm trying to get a loop to work with a function that prints a list and save the list for each row in a single new column.
I can run the loop, but I end up with only the results list for the last word repeated in every row in the new column.
library(vwr)
test = c("cat", "bat", "rat", "tow", "row")
test = data.frame(test)
for (i in test$test){
test$save[i] = levenshtein.neighbors(i,test$test)[1]}
Once the loop runs, I end up with test$save
as the list of neighbors for "row" ("tow") in every cell.
I want each cell in the test$save
column to have the neighbors for that word (i.e. "cat" should have "bat" and "rat"; "tow" should have "row"). Eventually, this will be with 100,000+ words in a dataset with 50 other columns, so I can't do too much manual work either.
Thanks for any help you can offer!