Re: [R] R-help: grep in for loop using index - doesn't work

2009-03-12 Thread baptiste auguie
Hi, your example is quite messy (neither reproducible or minimal). I think you could try the following, mdf <- data.frame(1:3) names(mdf) <- "147" i <- 147 mdf[ as.character(i) ] Hope this helps, baptiste On 11 Mar 2009, at 22:34, Mohan Singh wrote: Hi everyone I am trying to

Re: [R] R-help: grep in for loop using index - doesn't work

2009-03-11 Thread jim holtman
I think you have to convert the loop value to character; it is not recognized inside the quotes: #doesn't work, but now it should i<-147 p1 <- grep("QueryItem",c1data[as.character(i),],value=FALSE,fixed=FALSE) print(p1) # prints 0 Same thing goes for the 'for' loop: for(i in 137:270) { print(i)

[R] R-help: grep in for loop using index - doesn't work

2009-03-11 Thread Mohan Singh
Hi everyone I am trying to use grep in a for loop to compare a string value. It works if I use the actual index value but when I use the for loop index, it doesn't work. Any suggestions plz. Here is the code: data <- read.table(file="Sigmoid.csv", head=FALSE, sep=","); c1 <- data$V1 c2 <- dat

Re: [R] R-help: grep in for loop using index - doesn't work

2009-03-11 Thread Mohan Singh
Thanks very much Phil :) Worked prefect -Original Message- From: Phil Spector [mailto:spec...@stat.berkeley.edu] Sent: Wednesday, March 11, 2009 11:14 PM To: Mohan Singh Subject: Re: [R] R-help: grep in for loop using index - doesn't work Mohan - Sorry about that. I need to

Re: [R] R-help: grep in for loop using index - doesn't work

2009-03-11 Thread Mohan Singh
ccess the rows with data (just started R), so I created individual frames for data Cheers Mohan -Original Message- From: Phil Spector [mailto:spec...@stat.berkeley.edu] Sent: Wednesday, March 11, 2009 10:46 PM To: Mohan Singh Subject: Re: [R] R-help: grep in for loop using index - doesn&#

[R] R-help: grep in for loop using index - doesn't work

2009-03-11 Thread Mohan Singh
Hi everyone I am trying to use grep in a for loop to compare a string value. It works if I use the actual index value but when I use the for loop index, it doesn't work. Any suggestions plz. Here is the code: data <- read.table(file="Sigmoid.csv", head=FALSE, sep=","); c1 <- data$