i am updating the new column which will show if the name column have double space or extra space but its showing error.
i havemore than one column in my database
df7 <- data.frame(name_1 = c("ttt, hbue","mna,ssu huna","vga, pahk","hja, dhyn","cct, indo","nhu,nhuv"))
countSpaces <- function(s) { sapply(gregexpr(" ", s), function(p) { sum(p>=0) } ) }
name <- "name_1"
df7 <- df7 %>% mutate(across(`1. double space in name` = ifelse(countSpaces(df7[[name]])>1,"1. name contains uneccessary space"," ")))