Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

Hi,

In this rainy sunday, being sent out of home because some serious tidy-up and cleaning going on inside home :smile:

i decided i will find somewhere to grab a coffee, listen to some awesome music and explore possibilities with R programming.

Since i am not very proficient in coding, i will look for some ready code on the internet and will try to adapt it.

I believe some social media content will really make my demos and presentations shine, so let's see what we can do with Facebook API.

Result component link is at the bottom of this page, ready to be used,

What we want to achieve? See this viz.

http://snapplab.blogs.wm.edu/files/2013/12/fbnetwork3.jpg

First Step :

Log on to FB, visit this page, click on "get access token" (dont forget to authorize for friends data) :

https://developers.facebook.com/tools/explorer/?method=GET&path=716590462%3Ffields%3Did%2Cname

Here's the github link to the original code i found online. it gets your friend list and their friends to plot a network cluster to visualize their connections to each other. Will be intresting to try:

https://github.com/pablobarbera/Rdataviz/blob/master/code/05_networks.R

We have to wrap this inside a function, add a print to actually plot the graph, make the api key a variable so we can pass from the algorithm properties page.

Now let's configure our key and run the component :

Run the component and...!!!

The code basically plots the clusters, and creates a legend to show names of people right on the center of each cluster. You chan tweak the code to change plot parameters which will probably make it look visually more appealing, like this  :

Looking at the plot and names which i didnt include in the screenshot, i understand that they are mainly :

1) Work network

2) University friends

3) High-school friends,

4) Elementary school friends (yes we did find each other via facebook :smile:

5) Family

I believe that's a simple enough example of what clustering is, understanding different subcategories amongst a big list.

My next aim will be to replicate something similar but using a "product page" from facebook, visualizing people who "liked" the page. Any help is highly apreciated

Here's the re-usable component for SAP Predictive Analysis, download it and paste it into the apropriate folder which may look like

C:\Users\"usernamecomeshere"\SAP Predictive Components\RScript

Please note that the code is provided "as-is" and is not supported by SAP.

https://share.sap.com/a:rcoxsl/MyAttachments/3e3fc10c-3ae7-493b-a49f-a58c424e6711/

Happy coding :smile:


4 Comments