[R] How do I loop through strings?

dre968 alyalko at gmail.com
Wed Apr 22 21:39:51 CEST 2009


I read in a CSV file with Data <-
read.csv(file="FileName.csv",head=TRUE,sep=",")

the file containts strings in the 2nd and 3rd columns and each has about
1000 rows.  I need to either loop through the strings there looking for
strings that would trigger other logic or remove those rows and put them in
another array and loop through them in the new array.  I can't seem to get
the if statement to work on the Data strings.  it doesn't recognize the
string.  Oh the strings in the CSV file all have "" around them so Data[1,2]
is "ABC" but...

> if(Data[1,2]=="ABC") tester<-"True" else tester<-"False"
> tester
[1] "False"


What am I doing wrong?

-- 
View this message in context: http://www.nabble.com/How-do-I-loop-through-strings--tp23175824p23175824.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list