I need to select only records containing a string, starting from the first element but I do not want to use substring
because I should indicate the number of digits.
I tried to use grep/grepl
and ^(for starting from the first element) but my problem is that I have an external vector where grep should look.
There's an example:
hello <- c("720", "555", "556")
A$1 %in% substring(hello,1,3)
This works as I wish but I don't want to use substring
because I do not want to indicate the number of digits.
I'd like to use grep in someway:
grep(^hello, A$1)
Of course this doesn't work. Is there a way to do this?
Thanks Sabrina