convert email to lower to get count

I have a very big data of email id like below

Email
abc@LIVE.com
dfg@live.com
bhjus@Hotmail.com
bhuio@hotmail.com

now i am trying to create a summary of domain counts, i am trying like below but its very time taking , i am getting count of two domain count for lower case and upper case
domain count
HOTMAIL 1
hotmail 1

domain_ct <- df %>% select(Email) %>% filter(!is.na(Email)) %>% tolower(Email)
domain_ct <- as.data.frame(table(sub(".*@", "",domain_ct$Email )))

getting error
Error in tolower(., Email) : unused argument (Email)

do we have any other solution for this.....

The problem is that tolower takes as its first argument the vector to be changed and when you put it in a chain with %>% you are passing it the data frame produced by filter() and then Email. Try this as your first step.

domain_ct <- df %>% select(Email) %>% filter(!is.na(Email)) %>%
  mutate(Email = tolower(Email))

Alternately, here is a {base} R solution,

email <- c("abc@LIVE.com",
           "dfg@live.com",
           "bhjus@Hotmail.com",
           "bhuio@hotmail.com")
table(tolower(vapply(strsplit(email, "@"), `[[`, character(1), 2)))
#> 
#> hotmail.com    live.com 
#>           2           2

Created on 2020-09-14 by the reprex package (v0.3.0)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.