> On Jun 21, 2016, at 3:09 PM, William Dunlap via R-help
> wrote:
>
> You could remove all non-digits from the strings with
>> gsub("[^[:digit:]]+", "", x)
> [1] "0122" "" "" "89963" "1" "8"
> and then count the number of characters remaining with nchar
>> x[nchar(gsub("[^[:dig
You could remove all non-digits from the strings with
> gsub("[^[:digit:]]+", "", x)
[1] "0122" "" "" "89963" "1" "8"
and then count the number of characters remaining with nchar
> x[nchar(gsub("[^[:digit:]]+", "", x)) <= 1]
[1] "RTG" "GF TYHH" "KFTR1" "RT 8"
Or you
Hello,
I have a vector x of character strings:
x <- c("LM0122","RTG", "GF TYHH", "HJN 89963", "KFTR1","RT 8")
>From this vector, how can I extract the following character strings (i.e.,
>which contain 0 or 1 numeric value)
[1] "RTG" "GF TYHH" "KFTR1" "RT 8"
Thank you v
3 matches
Mail list logo