powered by
www
domain(x)
x1 <- "http://stackoverflow.com/questions/19020749/function-to-extract-domain-name-from-url-in-r" x2 <- "http://www.talkstats.com/" x3 <- "www.google.com" domain(x3) sapply(list(x1, x2, x3), domain)
Run the code above in your browser using DataLab