By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
SmartData Collective
  • Analytics
    AnalyticsShow More
    construction analytics
    5 Benefits of Analytics to Manage Commercial Construction
    5 Min Read
    benefits of data analytics for financial industry
    Fascinating Changes Data Analytics Brings to Finance
    7 Min Read
    analyzing big data for its quality and value
    Use this Strategic Approach to Maximize Your Data’s Value
    6 Min Read
    data-driven seo for product pages
    6 Tips for Using Data Analytics for Product Page SEO
    11 Min Read
    big data analytics in business
    5 Ways to Utilize Data Analytics to Grow Your Business
    6 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
Latest News
cloud-centric companies using network relocation
Cloud-Centric Companies Discover Benefits & Pitfalls of Network Relocation
Cloud Computing
construction analytics
5 Benefits of Analytics to Manage Commercial Construction
Analytics
database compliance guide
Four Strategies For Effective Database Compliance
Data Management
Digital Security From Weaponized AI
Fortifying Enterprise Digital Security Against Hackers Weaponizing AI
Security
DevOps on cloud
Optimizing Cost with DevOps on the Cloud
Development
Aa
SmartData 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
- Advertisement -

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)

- Advertisement -

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 helps with offsite SEO

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
Data Mining Vital Statistics Yields Fascinating Societal Insights
(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:

- Advertisement -

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

- Advertisement -
DavidMSmith June 10, 2009
Share this Article
Facebook Twitter Pinterest LinkedIn
Share
- Advertisement -

Follow us on Facebook

Latest News

cloud-centric companies using network relocation
Cloud-Centric Companies Discover Benefits & Pitfalls of Network Relocation
Cloud Computing
construction analytics
5 Benefits of Analytics to Manage Commercial Construction
Analytics
database compliance guide
Four Strategies For Effective Database Compliance
Data Management
Digital Security From Weaponized AI
Fortifying Enterprise Digital Security Against Hackers Weaponizing AI
Security

Stay Connected

1.2k Followers Like
33.7k Followers Follow
222 Followers Pin

You Might also Like

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
data mining is game changer for small businesses
Data Mining

Perform Data Mining With Web Scrapers to Track Prices

7 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 chatbots
AI Chatbots Can Help Retailers Convert Live Broadcast Viewers into Sales!
Chatbots
data-driven web design
5 Great Tips for Using Data Analytics for Website UX
Big Data

Quick Link

  • About
  • Contact
  • Privacy
Follow US

© 2008-23 SmartData Collective. All Rights Reserved.

Removed from reading list

Undo
Go to mobile version
Welcome Back!

Sign in to your account

Lost your password?