-
-
Save dsparks/4329876 to your computer and use it in GitHub Desktop.
doInstall <- TRUE | |
toInstall <- c("twitteR", "dismo", "maps", "ggplot2") | |
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")} | |
lapply(toInstall, library, character.only = TRUE) | |
searchTerm <- "#rstats" | |
searchResults <- searchTwitter(searchTerm, n = 1000) # Gather Tweets | |
tweetFrame <- twListToDF(searchResults) # Convert to a nice dF | |
userInfo <- lookupUsers(tweetFrame$screenName) # Batch lookup of user info | |
userFrame <- twListToDF(userInfo) # Convert to a nice dF | |
locatedUsers <- !is.na(userFrame$location) # Keep only users with location info | |
locations <- geocode(userFrame$location[locatedUsers]) # Use amazing API to guess | |
# approximate lat/lon from textual location data. | |
with(locations, plot(lon, lat)) | |
worldMap <- map_data("world") # Easiest way to grab a world map shapefile | |
zp1 <- ggplot(worldMap) | |
zp1 <- zp1 + geom_path(aes(x = long, y = lat, group = group), # Draw map | |
colour = gray(2/3), lwd = 1/3) | |
zp1 <- zp1 + geom_point(data = locations, # Add points indicating users | |
aes(x = lon, y = lat), | |
colour = "RED", alpha = 1/2, size = 1) | |
zp1 <- zp1 + coord_equal() # Better projections are left for a future post | |
zp1 <- zp1 + theme_minimal() # Drop background annotations | |
print(zp1) |
Hi,
I tried all suggestions above, but I still get this error:
Error : 1: failed to load HTTP resource
Error in .geocode(xx$place, oneRecord = oneRecord, extent = extent, progress = progress) :
object 'doc' not found
Any Solutions ?? Thanks in Advance
For error: Error : 1: failed to load HTTP resource
Use
locations <- geocode(locatedUsers)
instead of locations <- geocode(userFrame$location[locatedUsers])
run this code and my problem is when I try to run locations <- geocode(userFrame$location[locatedUsers]):
failed to load HTTP resource Error : 1: failed to load HTTP resource
And after this : Error in plot.window(...) : need finite 'xlim' values
Please, can you help me?
i also use locations <- geocode(locatedUsers) but this happened after đ Error in plot.window(...) : se necesitan valores finitos de 'xlim'
AdemĂĄs: Warning messages:
1: In min(x) : ningĂșn argumento finito para min; retornando Inf
2: In max(x) : ningun argumento finito para max; retornando -Inf
3: In min(x) : ningĂșn argumento finito para min; retornando Inf
4: In max(x) : ningun argumento finito para max; retornando -Inf
Hi, I also tried ALL suggestions above, but I still get this error:
any solution? Thanks