I am totally new in R and have the following problem: I want to create a new column V4 with the letter A only IF values in V2 are bigger or equal 1.2
This is my test data frame df:
V1 V2 V3
1 ABC 1.2 4.3
2 CFS 2.3 1.7
3 dgf 1.3 4.4
That's what I did
df$V4<-NA
for(i in 1:nrow(df)) {
xy=df[i,]$V2
if (grepl(>=1.2,xy))
df[i,]$V4 ="A"
}
}
It works fine when I just want exactly 1.2, but >= seems not to work. Has anyone an idea why?