Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. d$domain<-strsplit( d$email, "@")[[1]]
  2.  
  3. for (i in 1:length(row.names(d)){
  4. d$domain[i]<-unlist(strsplit( d$email[i], "@"))[2]
  5. }
  6.  
  7. d <- data.frame(email=rep(bob@bob.com, 10))
  8. d$address <- gsub("@.*", "", d$email)
  9. d$domain <- gsub(".*@", "", d$email)
  10.  
  11. library(stringr)
  12. str_split_fixed(d$email, "@", n = 2)
  13.  
  14. name <- "fakename@email.com"
  15. splitname <- strsplit(name, "@")
  16. emailid <- sapply(splitname, "[", 1)
  17. domain <- sapply(splitname, "[", 2)
  18.  
  19. matrix(unlist(strsplit(name,"@")),nrow=2)
  20.  
  21. parse.email <- function(emails) {
  22. email.list <- strsplit(emails, split = '@')
  23. # Preallocate the vectors
  24. n <- length(email.list)
  25. local <- vector(length = n)
  26. domain <- vector(length = n)
  27. for (i in 1:n){
  28. local[i] <- email.list[[i]][1]
  29. domain[i] <- email.list[[i]][2]
  30. }
  31. l <- list(local, domain)
  32. names(l) <- c('local', 'domain')
  33. return(l)}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement