[R] non alphabetical strings

Rui Barradas ru|pb@rr@d@@ @end|ng |rom @@po@pt
Sun Apr 28 23:41:43 CEST 2019


Hello,

There is a typo, the end colon is missing.

grepl(x, '[^[:alpha:]]')


Hope this helps,

Rui Barradas

Às 21:26 de 28/04/19, Jeff Newmiller escreveu:
> Use pattern "[^[:alpha]]" with grepl.
> 
> On April 28, 2019 12:50:37 PM PDT, Bert Gunter <bgunter.4567 using gmail.com> wrote:
>> ?grepl
>>
>> gives you a logical vector for indexing.
>>
>>
>> Bert Gunter
>>
>> "The trouble with having an open mind is that people keep coming along
>> and
>> sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>
>>
>> On Sun, Apr 28, 2019 at 11:54 AM Graeme Davidson <
>> graeme.r.davidson using gmail.com> wrote:
>>
>>> Hello All,
>>>
>>> I can’t find the answer for this so I thought I would ask you lovely
>>> people.
>>>
>>> I have a data frame with a column of names, some of which have
>>> non-alphabetical letters.
>>>
>>> How, do I extract the row indexes which do not meat the criteria of
>>> alphabetical [[:alpha:]].
>>>
>>> Thanks in advance
>>>
>>> All the best
>>>
>>> Graeme
>>>
>>>
>>> library(dplyr)
>>> my_df <- data.frame(name1 = c("david", "mo", "ma4tilda856", "steph",
>>> "hadley", "574383"),
>>>                      name2 = c("craig", "salah", "dahl", "paris",
>> "wick",
>>> "turing"), sex = c("m", "m", "f", "f", "m", "m”))
>>> my_df %>%
>>>    mutate_all(as.character)
>>>          [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>> 	[[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list