twitter


library(twitteR)
library(httr)

chennai = searchTwitter("#chennai", n=50)
chennai[[1]]$text
f=function(k){
for(i in 1:50)
{
  if(chennai[[i]]$isRetweet)
    {k=k+1}
}
return(k)}
f(0)
if(chennai[[10]]$isRetweet==T){print(TRUE)} else {print(FALSE)}


vec=c(1,2,3)

sum_vec=function(vec){
  sum=0
  for(i in 1:length(vec))
  {
    sum=sum+vec[i]
  }
  return(sum)}
sum_vec(vec)

library(RMySQL)
con=dbConnect(MySQL(),user="itlab",password="itlab@321", host="10.21.33.3",dbname="yelp_db")
business_data = dbGetQuery(conn = con, statement = "select * from business")

class(business_data)



city_count= dbGetQuery(conn = con, statement = "select count(*),state,city from business  group by state,city order by count(*) desc")
city_count=aggregate(x=business_data$id, by=list(business_data$state,business_data$city),FUN =length)



ordered_city_count=city_count[order(city_count$x,city_count$Group.2, decreasing = TRUE),]



business_count=aggregate((x=business_data$id), by=list(business_data$state),FUN=length)
business_count_1000=subset(business_count, business_count$x>1000)

Comments