Unlimited learning, half price | 50% off

Last chance! 50% off unlimited learning

Sale ends in


SocialMediaLab (version 0.23.2)

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

Description

Collect YouTube comments data for generating different types of networks

Usage

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.

Value

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

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.

See Also

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

Examples

Run this code

## 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)
## ---------------------------------------------

Run the code above in your browser using DataLab