Thank you for that Pascal. I changed this bit to the following:
result <- vector("list", (length(test1)-1)) for(i in 1:(length(test1)-1)) { for(j in i+1:length(test1)) { result[[i]][j-i] <- agrep(test1[i], test1[j], ignore.case = TRUE, value = TRUE, max.distance = 0.1) } } And now I get the error - Error in result[[i]][j - i] <- agrep(test1[i], test1[j], ignore.case = TRUE, : replacement has length zero What does this mean? On Tue, Dec 11, 2012 at 1:24 PM, Pascal Oettli <kri...@ymail.com> wrote: > Hi, > > There is a mistake in the first line. It should be: > > for(i in 1:(length(test1)-1)) > > Regards, > Pascal > > > Le 11/12/2012 16:01, surekha nagabhushan a écrit : > >> Hi all. >> >> This is my first message at R-help...so I'm hoping I have some beginner's >> luck and get some good help for my problem! >> >> FYI I have just started using R recently so my knowledge of R is pretty >> preliminary. >> >> Okay here is what I need help with - I need to know how to use agrep in a >> for loop. >> >> I need to compare elements of a vector of names with other elements of the >> same vector. >> >> However if I use something like this: >> >> for(i in 1:length(test1)-1) >> { >> for(j in i+1:length(test1)) >> { >> result[[i]][j] <- agrep(test1[i], test1[j], ignore.case = TRUE, value = >> TRUE, max.distance = 0.1) >> } >> >> } >> >> I get an error message saying - invalid 'pattern' argument. -* Error in >> >> agrep(test1[i], test1[j], ignore.case = TRUE, value = TRUE, max.distance = >> 0.1) : * >> * invalid 'pattern' argument* >> >> >> Test 1 being - c("Vashi", "Vashi,navi Mumbai", "Thane", "Vashi,new >> Mumbai", >> "Thana", "Surekha", "Thane(w)", "surekhaN") >> >> This is the first time I'm using agrep, I do not understand how it works >> fully... >> >> Kindly help... >> >> Thank you. >> >> Su. >> >> [[alternative HTML version deleted]] >> >> ______________________________**________________ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help> >> PLEASE do read the posting guide http://www.R-project.org/** >> posting-guide.html <http://www.R-project.org/posting-guide.html> >> and provide commented, minimal, self-contained, reproducible code. >> >> [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.