Hi,
I am trying to find telephone numbers in my data frame.
I would like to specify that if there is any comments containing at least 10 consecutive numbers it should be coded as TMC.Number.
I can only find records containing numbers
library(tidyverse)
sample_data <- data.frame(stringsAsFactors=FALSE,
URN = c(94, 59, 100, 7),
all_comment = c("number 12587 is funny", "bla bla bla", "call 45785854844", "all 100%"))
sample_data
library(dplyr)
library(stringr)
coding.result <- sample_data %>%
mutate(
TMC.Number = if_else(str_detect(all_comment, regex("1|2|3|4|5|6|7|8|9", ignore_case = TRUE, multiline = TRUE))
&!str_detect(all_comment, regex("100%", ignore_case = TRUE)), 1, 0)
)
coding.result
Can you help?