By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
SmartData CollectiveSmartData Collective
  • Analytics
    AnalyticsShow More
    data Analytics instagram stories
    Data Analytics Helps Marketers Make the Most of Instagram Stories
    15 Min Read
    analyst,women,looking,at,kpi,data,on,computer,screen
    What to Know Before Recruiting an Analyst to Handle Company Data
    6 Min Read
    AI analytics
    AI-Based Analytics Are Changing the Future of Credit Cards
    6 Min Read
    data overload showing data analytics
    How Does Next-Gen SIEM Prevent Data Overload For Security Analysts?
    8 Min Read
    hire a marketing agency with a background in data analytics
    5 Reasons to Hire a Marketing Agency that Knows Data Analytics
    7 Min Read
  • Big Data
  • BI
  • Exclusive
  • IT
  • Marketing
  • Software
Search
© 2008-23 SmartData Collective. All Rights Reserved.
Reading: Tweeting from R
Share
Notification Show More
Aa
SmartData CollectiveSmartData Collective
Aa
Search
  • About
  • Help
  • Privacy
Follow US
© 2008-23 SmartData Collective. All Rights Reserved.
SmartData Collective > Big Data > Data Mining > Tweeting from R
Data Mining

Tweeting from R

DavidMSmith
Last updated: 2009/06/10 at 5:06 PM
DavidMSmith
4 Min Read
SHARE

Over at Cerebral Mastication, you can find the code for a function that will allow you to send a status update to Twitter directly from the R console. The code’s pretty short, so here it is in full:

library(“RCurl”)
opts <->curlOptions(header = FALSE, 
  userpwd = “username:password”, netrc = FALSE)

tweet <->function(status){
  method <->“http://twitter.com/statuses/update.xml?status=”
  encoded_status <->URLencode(status)
  request <->paste(method,encoded_status,sep = “”)
  postForm(request,.opts = opts)
}

With this function, you can send a tweet simply by using the update function:

tweet(“This tweet comes from R! #rstats”)

More Read

data mining

Data Mining Technology Helps Online Brands Optimize Their Branding

Can Data Mining Aid with Off-Page SEO Strategies?
3 Data Mining Tips for Companies Trying to Understand their Customers
5 Data Mining Tips to Leverage the Benefits of Surveys
Perform Data Mining With Web Scrapers to Track Prices
(CM called the function update, but that overloads an existing function in R.) Now, you may be asking yourself, “Why would anyone want to do this?”. And it’s an excellent question: why use the R console when there are plenty of good applications that interface with Twitter already? But consider: what if you had an automated R application running in production, and needed to alert a large number of users when an event occurs: a long simulation has completed, a stock reaches a predetermined price, a chemical assay has detected a compound of interest. Now, …

Over at Cerebral Mastication, you can find the code for a function that will allow you to send a status update to Twitter directly from the R console. The code’s pretty short, so here it is in full:

library(“RCurl”)
opts <- curlOptions(header = FALSE, 
  userpwd = “username:password”, netrc = FALSE)

tweet <- function(status){
  method <- “http://twitter.com/statuses/update.xml?status=”
  encoded_status <- URLencode(status)
  request <- paste(method,encoded_status,sep = “”)
  postForm(request,.opts = opts)
}

With this function, you can send a tweet simply by using the update function:

tweet(“This tweet comes from R! #rstats”)

(CM called the function update, but that overloads an existing function in R.) Now, you may be asking yourself, “Why would anyone want to do this?”. And it’s an excellent question: why use the R console when there are plenty of good applications that interface with Twitter already? But consider: what if you had an automated R application running in production, and needed to alert a large number of users when an event occurs: a long simulation has completed, a stock reaches a predetermined price, a chemical assay has detected a compound of interest. Now, with just a few lines of code and the RCurl package, you have a way of doing just that.

Cerebral Mastication: Twitter from R… Sure, Why Not!

Link to original post

DavidMSmith June 10, 2009
Share This Article
Facebook Twitter Pinterest LinkedIn
Share

Follow us on Facebook

Latest News

smart home data
7 Mind-Blowing Ways Smart Homes Use Data to Save Your Money
Big Data
ai low code frameworks
AI Can Help Accelerate Development with Low-Code Frameworks
Artificial Intelligence
data Analytics instagram stories
Data Analytics Helps Marketers Make the Most of Instagram Stories
Analytics
data breaches
How Hospital Security Breaches Devastate Local Communities
Policy and Governance

Stay Connected

1.2k Followers Like
33.7k Followers Follow
222 Followers Pin

You Might also Like

data mining
Data Mining

Data Mining Technology Helps Online Brands Optimize Their Branding

7 Min Read
data mining helps with offsite SEO
Data Mining

Can Data Mining Aid with Off-Page SEO Strategies?

10 Min Read
using data mining to learn more about customers
Big Data

3 Data Mining Tips for Companies Trying to Understand their Customers

6 Min Read
surveys data
Data Mining

5 Data Mining Tips to Leverage the Benefits of Surveys

11 Min Read

SmartData Collective is one of the largest & trusted community covering technical content about Big Data, BI, Cloud, Analytics, Artificial Intelligence, IoT & more.

ai in ecommerce
Artificial Intelligence for eCommerce: A Closer Look
Artificial Intelligence
AI and chatbots
Chatbots and SEO: How Can Chatbots Improve Your SEO Ranking?
Artificial Intelligence Chatbots Exclusive

Quick Link

  • About
  • Contact
  • Privacy
Follow US
© 2008-23 SmartData Collective. All Rights Reserved.
Go to mobile version
Welcome Back!

Sign in to your account

Lost your password?