Guest User

Untitled

a guest
Apr 23rd, 2018
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. v1 <- c("I will try to fix you usman@usman.com", "I will try to fix you", "Zombies Zombies xyz@ymail.com")
  2. v2 < c("ABC", "XYZ", "Oh Game")
  3. dx <- data.frame(v1, v2)
  4.  
  5. ABC usman@usman.com
  6. XYZ NA
  7. Oh Game xyz@ymail.com
  8.  
  9. dx$emails <- sapply(dx$v1, function(x) {
  10. email <- regmatches(x, regexpr("[[:alnum:]]+\@[[:alpha:]]+\.com", x))
  11. (result <- ifelse(identical(email, character(0)), NA, email))
  12. })
Add Comment
Please, Sign In to add comment