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]]
?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 at 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 at 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]]
Use pattern "[^[:alpha]]" with grepl. On April 28, 2019 12:50:37 PM PDT, Bert Gunter <bgunter.4567 at 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 at 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 at 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 at 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.-- Sent from my phone. Please excuse my brevity.