I have a dataframe with string values
id str
a 1
b 10
c 0
d 102
e 010
I need to create a flag such that if there is a 0 in the str, the flag is 1 else, the flag is 0
I'm using the following code :
df$flag <-ifelse(grep('0', df$str) == "1", 1, 0)
But this returns less rows than the number of total rows in df.
On inspection i found that
grep('0', df$str[1]) returns int(0)
whereas grep('0', df$str[2]) returns 1
Any idea how I could use this