1. Dado el vector de emails:
emails <- c("john.doe@ivyleague.edu", "education@world.gov", "dalai.lama@peace.org",
            "invalid.edu", "quant@bigdatacollege.edu", "cookie.monster@sesame.tv")
grepl(---)
hits <- ---
  1. Dado el vector de emails:
emails <- c("john.doe@ivyleague.edu", "education@world.gov", "dalai.lama@peace.org",
            "invalid.edu", "quant@bigdatacollege.edu", "cookie.monster@sesame.tv")
grepl(---)
hits <- ---
  1. Dado el vector de emails:
emails <- c("john.doe@ivyleague.edu", "education@world.gov", "dalai.lama@peace.org",
            "invalid.edu", "quant@bigdatacollege.edu", "cookie.monster@sesame.tv")

Usa sub() para sustituir los dominios de los email que acaban en .edu por “midominio.edu”

sub()
sub(pattern = "@.*\\.edu$", replacement = "@midominio.edu", x=emails)
## [1] "john.doe@midominio.edu"   "education@world.gov"     
## [3] "dalai.lama@peace.org"     "invalid.edu"             
## [5] "quant@midominio.edu"      "cookie.monster@sesame.tv"
  1. Dado el vector:
cities <- c("new york", "los angeles", "san francisco")

Escribe el código para obtener la salida:

## [1] "nuw york"      "los ungeles"   "sun francisco"
sub(---)
  1. Dado el vector:
animals <- c("cat", "moose", "impala", "ant", "kiwi")

Escribe el código para obtener la salida:

## [1] "cat"    "maasa"  "ampala" "ant"    "kawa"
gsub(---)