Description Usage Arguments Details Value Note Author(s) See Also Examples
View source: R/CollectDataYoutube.R
Collect YouTube comments data for generating different types of networks
1 | CollectDataYoutube(videoIDs, apiKeyYoutube, verbose, writeToFile, maxComments)
|
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
|
apiKeyYoutube |
character string, specifying the Google Developer API Key used for authentication. |
verbose |
logical. If |
writeToFile |
logical. If |
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 |
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
.
A data frame object of class dataSource.youtube
that can be
used for creating unimodal networks (CreateActorNetwork
).
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.
Timothy Graham <timothy.graham3@uq.net.au> & Robert Ackland <robert.ackland@anu.edu.au>
AuthenticateWithYoutubeAPI
must be run first or no data will
be collected.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.