CollectDataYoutube: Note: this function is DEPRECATED and will be removed in a...

Description Usage Arguments Details Value Note Author(s) See Also Examples

View source: R/CollectDataYoutube.R

Description

Collect YouTube comments data for generating different types of networks

Usage

1
CollectDataYoutube(videoIDs, apiKeyYoutube, verbose, writeToFile, maxComments)

Arguments

videoIDs

character vector, specifying one or more YouTube video IDs. For example, if the video URL is 'https://www.youtube.com/watch?v=W2GZFeYGU3s', then use videoIDs='W2GZFeYGU3s'. For multiple videos, the function GetYoutubeVideoIDs can be used to create a vector object suitable as input for videoIDs.

apiKeyYoutube

character string, specifying the Google Developer API Key used for authentication.

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.

writeToFile

logical. If TRUE then the data is saved to file in current working directory (CSV format), with filename denoting current system time. Default is FALSE.

maxComments

numeric integer, specifying how many 'top-level' comments to collect from each video. This value *does not* take into account 'reply' comments (i.e. replies to top-level comments), therefore the total number of comments collected may be higher than maxComments. By default this function attempts to collect all comments.

Details

This function collects YouTube comments data for one or more YouTube videos. It structures the data into a data frame of class dataSource.youtube, ready for creating networks for further analysis.

CollectDataYoutube collects public comments from YouTube videos, using the YouTube API.

The function then finds and maps the relationships of YouTube users who have interacted with each other (i.e. user i has replied to user j or mentioned user j in a comment) and structures these relationships into a data frame format suitable for creating unimodal networks (CreateActorNetwork).

For multiple videos, the user may wish to use the function GetYoutubeVideoIDs, which creates a character vector of video IDs from a plain text file of YouTube video URLs, which can then be used for the videoIDs argument of the function CollectDataYoutube.

Value

A data frame object of class dataSource.youtube that can be used for creating unimodal networks (CreateActorNetwork).

Note

Currently supported network types:

- unimodal 'actor' network; CreateActorNetwork

Data generated using this function is *not* suitable for dynamic networks. Dynamic YouTube comments networks are not currently implemented in the SocialMediaLab package. This will be implemented in a future release.

Note on maxComments argument: Due to quirks/specifications of the Google API, it is currently not possible to specify the exact number of comments to return from the API using maxResults argument (i.e. including comments that are replies to top-level comments). Therefore, the number of comments collected is usually somewhat greater than maxComments, if a value is specified for this argument. For example, if a video contains 10 top-level comments, and one of these top-level comments has 5 'child' or reply comments, then the total number of comments collected will be equal to 15. Currently, the user must 'guesstimate' the maxResults value, to collect a number of comments in the order of what they require.

Author(s)

Timothy Graham <timothy.graham3@uq.net.au> & Robert Ackland <robert.ackland@anu.edu.au>

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
  # Use your own Google Developer API Key here:
  myApiKey <- "1234567890"

  # Authenticate with the Google API
  apiKeyYoutube <- AuthenticateWithYoutubeAPI(apiKeyYoutube=myApiKey)

  # Generate a vector of YouTube video IDs to collect data from
  # (or use the function `GetYoutubeVideoIDs` to automatically
  # generate from a plain text file of video URLs)
  videoIDs <- c("W2GZFeYGU3s","mL27TAJGlWc")

  # Collect the data using function `CollectDataYoutube`
  myYoutubeData <- CollectDataYoutube(videoIDs,apiKeyYoutube,writeToFile=FALSE)

  # Create an 'actor' network using the function `CreateActorNetwork`
  g_actor_youtube <- CreateActorNetwork(myYoutubeData)

## End(Not run)

SocialMediaLab documentation built on May 29, 2017, 9:41 p.m.