Re: [R] How do you use agrep inside a loop

2012-12-13 Thread surekha nagabhushan
Thank you all it worked after I checked for length of agrep's result :) On Tue, Dec 11, 2012 at 6:11 PM, Rui Barradas wrote: > Hello, > > Inline. > > Em 11-12-2012 12:04, surekha nagabhushan escreveu: > >> Rui, >> >> >> I have initialized it...doesn't seem to help... >> >> result_vector <- vecto

Re: [R] How do you use agrep inside a loop

2012-12-11 Thread Rui Barradas
Hello, Inline. Em 11-12-2012 12:04, surekha nagabhushan escreveu: Rui, I have initialized it...doesn't seem to help... result_vector <- vector() No! This must be just before the loop in 'j' result <- vector("list", (length(test1)-1)) for(i in 1:(length(test1)-1)) { for(j in (i+1):length

Re: [R] How do you use agrep inside a loop

2012-12-11 Thread surekha nagabhushan
Rui, I have initialized it...doesn't seem to help... result_vector <- vector() result <- vector("list", (length(test1)-1)) for(i in 1:(length(test1)-1)) { for(j in (i+1):length(test1)) { result_vector[j-i] <- agrep(test1[i], test1[j], ignore.case = TRUE, value = TRUE, max.distance = 0.1)

Re: [R] How do you use agrep inside a loop

2012-12-11 Thread Rui Barradas
Hello, See if this is it. You must reinitialize 'result_vector' just before the loop that constructs it. test1 <- c("Vashi", "Vashi,navi Mumbai", "Thane", "Vashi,new Mumbai", "Thana", "Surekha", "Thane(w)", "surekhaN") result <- vector("list", (length(test1)-1)) for(i in 1:(length(te

Re: [R] How do you use agrep inside a loop

2012-12-11 Thread Pascal Oettli
Hello, Right, I didn't notice. Apologies. Pascal Le 11/12/2012 19:55, Rui Barradas a écrit : Hello, And another error in line 2. It should be for(j in (i+1):length(test1)) Hope this helps, Rui Barradas Em 11-12-2012 07:54, Pascal Oettli escreveu: Hi, There is a mistake in the first li

Re: [R] How do you use agrep inside a loop

2012-12-11 Thread surekha nagabhushan
Pascal, result_vector <- vector() result <- vector("list", (length(test1)-1)) for(i in 1:(length(test1)-1)) { for(j in (i+1):length(test1)) { result_vector[j-i] <- agrep(test1[i], test1[j], ignore.case = TRUE, value = TRUE, max.distance = 0.1) } result[[i]]<- result_vector } I'm not sur

Re: [R] How do you use agrep inside a loop

2012-12-11 Thread Rui Barradas
Hello, And another error in line 2. It should be for(j in (i+1):length(test1)) Hope this helps, Rui Barradas Em 11-12-2012 07:54, Pascal Oettli escreveu: 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

Re: [R] How do you use agrep inside a loop

2012-12-11 Thread Pascal Oettli
Hello, Probably because 'result' doesn't have the expected size/number of dimension. How do you create it? Regards, Pascal Le 11/12/2012 19:46, surekha nagabhushan a écrit : Thank you for that Pascal. I changed this bit to the following: result <- vector("list", (length(test1)-1)) for(i i

Re: [R] How do you use agrep inside a loop

2012-12-11 Thread surekha nagabhushan
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

Re: [R] How do you use agrep inside a loop

2012-12-10 Thread Pascal Oettli
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

[R] How do you use agrep inside a loop

2012-12-10 Thread surekha nagabhushan
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.