Learn R Programming

SocialMediaLab (version 0.23.2)

CollectDataFacebook: Note: this function is DEPRECATED and will be removed in a future release.

Description

Collect data from Facebook pages for generating different types of networks

Usage

CollectDataFacebook(pageName, rangeFrom, rangeTo, verbose, n, writeToFile,
  credential = NULL)

Arguments

pageName
character string, specifying the name of the Facebook page. For example, if page is: https://www.facebook.com/StarWars, then pageName="StarWars".
rangeFrom
character string, specifying a 'start date' for data collection, in the format YYYY-MM-DD. For example, to collect data starting from July 4th 2015, rangeFrom would be "2015-07-04". Default value is current system date minus one week (i.e. the date 7 days ago).
rangeTo
character string, specifying an 'end date' for data collection, in the format YYYY-MM-DD. For example, to collect data until December 25th 2015, rangeFrom would be "2015-12-25". Default value is the current system date.
verbose
logical. If TRUE then this function will output runtime information to the console as it computes. Useful diagnostic tool for long computations. Default is FALSE.
n
numeric, maximum number of comments and likes to return (see getPost in Rfacebook package). Default value is 1000.
writeToFile
logical. If TRUE then the data is saved to file in current working directory (CSV format), with filename denoting rangeFrom, rangeTo, and pageName.
credential
Optional, a credential object created by Authenticate.

Value

A data frame object of class dataSource.facebook that can be used with Create.

Details

This function collects data from Facebook pages (i.e. post data and comments/likes data within posts), and structures the data into a data frame of class dataSource.facebook, ready for creating networks for further analysis.

CollectDataFacebook collects public 'post' data from a given Facebook page, including comments and 'likes' from within each post.

The function then finds and maps the edgeTypes between users and posts, and structures these relationships into a format suitable for creating bimodal networks using CreateBimodalNetwork.

A date range must be specified for collecting post data using rangeFrom and rangeTo (i.e. data will be collected from posts posted within the date range). If no date range is supplied, then the default is the current system date minus one week (i.e. 7 days leading up to current system date).

See Also

Authenticate must be run first or no data will be collected.

Examples

Run this code

## Not run: ------------------------------------
#   ## Use your own values for myAppID and myAppSecret
#   appID <- "xxxx"
#   appSecret <- "yyyy"
# 
#   ## Collect data and create bimodal network
# 
#   g_bimodal_facebook_star_wars <- Authenticate("Facebook",
#   appID = appID, appSecret = appSecret) %>%
#   SaveCredential("FBCredential.RDS") %>%
#   Collect(pageName="StarWars", rangeFrom="2015-03-01",
#   rangeTo="2015-03-02", writeToFile=FALSE) %>%
#   Create("Bimodal")
# 
#   ## Create a dynamic network using the saved credentials
# 
#   g_bimodal_facebook_star_wars_dynamic <-
#   LoadCredential("FBCredential.RDS") %>%
#   Collect(pageName="StarWars", rangeFrom="2015-03-01",
#   rangeTo="2015-03-02", writeToFile=FALSE) %>%
#   Create("dynamic")
## ---------------------------------------------

Run the code above in your browser using DataLab