Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Mastering Social Media Mining with R

You're reading from  Mastering Social Media Mining with R

Product type Book
Published in Sep 2015
Publisher
ISBN-13 9781784396312
Pages 248 pages
Edition 1st Edition
Languages
Concepts

Table of Contents (13) Chapters

Mastering Social Media Mining with R
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
1. Fundamentals of Mining 2. Mining Opinions, Exploring Trends, and More with Twitter 3. Find Friends on Facebook 4. Finding Popular Photos on Instagram 5. Let's Build Software with GitHub 6. More Social Media Websites Index

The order of stories on a user's home page


In Facebook, when we open the home page we see multiple newsfeeds. These newsfeed are updated continuously, let's try to imitate the same in R. The following code will sort the newsfeeds in an order based on the interactions, as well as the recency of publishing. If you face any problems here, check the version of the API and retry with the API of Version 2.3. The code is as follows:

newsfeed<- getNewsfeed(token, n = 200)
head(newsfeed, 20)
newsfeed$datetime<- format.facebook.date(newsfeed$created_time)
currdate<- Sys.time()
maxdiff<- max(difftime(currdate, newsfeed$datetime, units="hours"))
newsfeed$priority<- maxdiff - difftime(currdate, newsfeed$datetime, units="hours")
newsfeed$priority<- as.numeric(newsfeed$priority)
fnpriority<- function(x){(x-min(x))/(max(x)-min(x))}
newsfeed$priority<- fnpriority(newsfeed$priority) *100
newsfeed$plikes_count<- fnpriority(newsfeed$likes_count) *100
newsfeed$pcomments_count<- fnpriority...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}