TwitteR (R's Twitter API)- unable to acquire tweets when specifying geocode - r

I'm currently using the TwitteR package in R. I'm able to acquire tweets without specifying the geocode, however when I specify the geocode, I get an error message which I give below:
#setup permission using relevant API keys in setup_twitter_oauth
searchTwitter("dog") #this line works
searchTwitter("dog", geocode = '40.714997,-73.91623, 10mi') #this line doesn't work
#returns "Error in twInterfaceObj$doAPICall(cmd, params, "GET", ...) : client error: (403) Forbidden"
The geocode I included is in New York City (I just chose a place with a high population density).

Works for me if I remove the space in the geocode argument:
searchTwitter("dog", geocode = '40.714997,-73.91623,10mi')

Related

twitteR packaging throwing error when trying to search for tweets by geocode

I am trying to collect tweets based on a geolocation using the searchTwitter function.
geocode = ="40.6687,74.1143,1mi" text = "" count = 200 bList<- searchTwitter(text, n=count, geocode=geocode)
When I run this code, I get an error stating "200 tweets were requested but the API can only return 0". I am not looking for tweets more than 7 days old and have no whitespace in my geocode, which were solutions to previously asked questions about this function.
Why am I getting this error and how can I fix it?
I have tried looking at similar problems online but I cannot figure out why there is an error.

R googleway bug in geocoding with address

I have some problem with the google_geocode function in googleway package. At first I've just tried it with a simple address:
key <- MyKey
df <- google_geocode(address = "5 Rue J-F Kennedy 8332 Luxembourg",
key = key,
simplify = TRUE)
And got the following message:
Error in value[[3L]](cond) :
There was an error downloading results. Please manually check the following URL is valid by entering it into a browswer. If valid, please file a bug report citing this URL (note: your API key has been removed, so you will need to add that back in)
https://maps.googleapis.com/maps/api/geocode/json?&address=5+rue+j-f+kennedy+8332+luxembourg&key=
I'd pasted it to my browser, and it was OK. Any idea?

How to get lat long for indian cities in R?

I am trying to get lat long for Indian cities through ggmap package. Below is the code I have tried but it results in an error.
I created a vector with sample cities
library(ggmap)
mycities1<- c("Hyderabad","Chennai","Bangalore","Cochin","ARNHEM","London")
str(mycities1)
geocode(mycities1[1])
This is throwing out NA values though my city names are class of character.
Warning message: geocode failed with status OVER_QUERY_LIMIT, location
= "Hyderabad
Please change the source argument to dsk.
geocode(as.character(mycities1[1]), source = "dsk")
This is due to recent google-API changes.
There is also a current github-issue (or several actually) which adresses that problem.
geocode failed with status OVER_QUERY_LIMIT, location = "XXX" --> you
have not registered a correct and billing-enabled Google Maps API key
using register_google() (ggmap v2.7,903). Enabling billing is a
specific step after (!) adding your credit card information.

How can I avoid Twitter API rate limits when returning a user's followers?

I have seen a few posts about this, but I have not been able to use any of the suggested code for the way I have my program set up. I am not very good at R but I need this information for a Political Science class. Could someone please help me figure out a way to avoid receiving the error message "Warning message: In twInterfaceObj$doAPICall(cmd, params, method, ...) : Rate limit encountered & retry limit reached - returning partial results." Thank you in advance! The code I am running is below:
# install and load packages
install.packages("twitteR")
install.packages("ROAuth")
install.packages("base64enc")
install.packages("plyr")
library("twitteR")
library("ROAuth")
library("base64enc")
library("plyr")
# Establish the connection (do this once)
cred$handshake(cainfo="cacert.pem")
#setup Twitter
setup_twitter_oauth('Consumer Key - XXXXXXXXXX', Consumer Secret -
'XXXXXXXXXX', API Key - 'XXXXXXXXXX', API Secret - 'XXXXXXX')
#store the user
user <- getUser('JackPosobiec')
#return a list of followers
Posobiecfollowers <- user$getFollowers(n=NULL)
Posobiecfollowers
#save followers in a data set
followers.df = ldply(followers, function(t) t$toDataFrame())
write.csv(followers.df, file = "JackPosobiecfollowersfile.csv")

Valid client and signature using ggmap package in R

I am using ggmap package in R software in order to geocode a list of addresses. The counting is over 2500 - Googles diary quota for free users.
I have been searched about it and I found out that it is possible to geocode 100 thousand addresses per day if you have an account. I decided to open an account and I received a message that I have 60 trial days and they gave a 300 dollars credit. Despite this, I didnt discover where I can find the "client" and "signature" options that ggmap requires.
If someone can tell me where I can find it, please let me know!
My aim is to make Google searches by the address. If address is not recognized, then I make it searches for the local using the zip code. Here is what I am doing:
library(RJSONIO)
library(RCurl)
getGeoData <- function(location, api_key){
location <- gsub(' ','+',location)
geo_data <- getURL(paste("https://maps.googleapis.com/maps/api/geocode/json?address=",location,sprintf("&key=%s",api_key), sep=""))
geo_data <- fromJSON(geo_data)
if(geo_data$status=="ZERO_RESULTS"){
return(NA)
} else return(geo_data$results[[1]]$geometry$location)
}
New error:
getGeoData(basefinal$cep[6793], "MY KEY")[[2]]
Error in getGeoData(basefinal$cep[6793], "MY KEY")[[2]] :
subscript out of bounds

Resources