I am new to R and am trying to use the SocialMediaMineR package to resolve shortened URLs that I have stored in a csv dataset. This is done with the command get_url, which requires a vector of characters as the URLs to be resolved.
Let us say I want to resolve three URLS. If I manually create a vector with those three characters and launch the command, it works:
url<- c("http://buff.ly/1bH9XaL", "http://buff.ly/1I4REcx", "http://buff.ly/1kMqoFs")
get_url(url, return.df = T)
url_list = read.csv("~/Desktop/url2.csv", header = F)
Error : length(url) == 1 is not TRUE
> url_list<-read.csv("~/Desktop/url2.csv", header = F)
structure(list(V1 = structure(1:3, .Label = c("http://buff.ly/1bH9XaL",
"http://buff.ly/1I4REcx", "http://buff.ly/1kMqoFs"), class = "factor")), .Names = "V1", class = "data.frame", row.names = c(NA,
First of all you haven't read the data using argument
stringsAsFactors = FALSE, so you have a column of objects of class
factor. You must therefore do
url_list$V1 <- as.character(url_list$V1)
After this the following seems to work.
Note: The proper way of reading in the data would have been, like I've said above,
url_list = read.csv("~/Desktop/url2.csv", header = F, stringsAsFactors = FALSE)