#' Return Column Types
#'
#' This function returns a cols() that specifies
#' the type of data in columns returned by either
#' the GetComments() function or the SearchSubreddit()
#' function
#' @param type One of c("thread", "comment")
#' @keywords reddit subreddit search API
#' @export
#' @examples
#' RedditColTypes("comment")
RedditColTypes <- function(type) {
if (type == "comment") {
return(cols(.default = col_character(),
"approved_at_utc" = col_integer(),
"likes" = col_character(),
"user_reports" = col_integer(),
"saved" = col_logical(),
"banned_at_utc" = col_integer(),
"gilded" = col_integer(),
"archived" = col_logical(),
"can_mod_post" = col_logical(),
"ups" = col_integer(),
"score" = col_integer(),
"downs" = col_integer(),
"edited" = col_character(),
"collapsed" = col_logical(),
"is_submitter" = col_logical(),
"stickied" = col_logical(),
"can_gild" = col_logical(),
"score_hidden" = col_logical(),
"created_utc" = col_integer(),
"controversiality" = col_double(),
"depth" = col_integer()
))
} else if (type == "thread") {
return(cols(.default = col_character(),
"view_count" = col_integer(),
"num_crossposts" = col_integer(),
"score" = col_integer(),
"over_18" = col_logical(),
"gilded" = col_integer(),
"stickied" = col_logical(),
"created" = col_integer(),
"ups" = col_integer(),
"num_comments" = col_integer(),
"is_self" = col_logical()
))
} else stop("Invalid parameter (must be \"thread\" or \"comment\")")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.