This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```r | |
p_load_gh("jcheng5/bubbles", "trinker/qdapTools") | |
x <- runif(26) | |
colfunc <- colorRampPalette(c("white", "red")) | |
cols <- colfunc(length(sort(unique(x)))) | |
bubbles(value = x, label = LETTERS, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!require("pacman")) install.packages("pacman") | |
pacman::p_load(dplyr, tidyr, wakefield) | |
set.seed(10) | |
dat <- r_data_frame(n = 10000, | |
race, | |
age, | |
sex | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Transform Model Output for Use with the LDAvis Package | |
#' | |
#' Convert a \pkg{topicmodels} output into the JSON form required by the \pkg{LDAvis} package. | |
#' | |
#' @param model A \code{\link[]{topicmodel}} object. | |
#' @param \ldots Currently ignored. | |
#' @seealso \code{\link[LDAvis]{createJSON}} | |
#' @export | |
#' @examples | |
#' \dontrun{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Find Optimal Number of Topics | |
#' | |
#' Iteratively produces models and then compares log likelihoods in a graphical output. | |
#' | |
#' @param x A \code{\link[tm]{DocumentTermMatrix}}. | |
#' @param max.k Maximum number of topics to fit (start small [i.e., default of 30] and add as necessary). | |
#' @param \ldots Ignored. | |
#' @return Returns the \code{\link[base]{data.frame}} of k (number of topics) and the associated log likelihood. | |
#' @references \url{http://stats.stackexchange.com/a/25128/7482} | |
#' @keywords k topicmodel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Find Optimal Number of Topics | |
#' | |
#' Iteratively produces models and then compares of the harmonic mean of the log likelihoods in a graphical output. | |
#' | |
#' @param x A \code{\link[tm]{DocumentTermMatrix}}. | |
#' @param max.k Maximum number of topics to fit (start small [i.e., default of 30] and add as necessary). | |
#' @param burnin Object of class \code{"integer"}; number of omitted Gibbs iterations at beginning, by default equals 0. | |
#' @param iter Object of class \code{"integer"}; number of Gibbs iterations, by default equals 2000. | |
#' @param keep Object of class \code{"integer"}; if a positive integer, the log-likelihood is saved every keep iterations. | |
#' @param method The method to be used for fitting; currently \code{method = "VEM"} or \code{method= "Gibbs"} are supported. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Find Optimal Number of Topics | |
#' | |
#' Iteratively produces models and then compares the harmonic mean of the log | |
#' likelihoods in a graphical output. | |
#' | |
#' @param x A \code{\link[tm]{DocumentTermMatrix}}. | |
#' @param max.k Maximum number of topics to fit (start small [i.e., default of | |
#' 30] and add as necessary). | |
#' @param harmonic.mean Logical. If \code{TRUE} the harmonic means of the | |
#' log likelihoods are used to determine k (see |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Business Radar Plot | |
#' | |
#' Given a \code{\link[base]{data.frame}} with \code{problems}, \code{category}, \code{importance} columns, create a radar plot of problems arranged in a military style radar sequence. | |
#' | |
#' @param data A \code{\link[base]{data.frame}} with the following columns: | |
#' \item{problems}{A character vector listing the problems} | |
#' \item{category}{A character vector grouping the problems} | |
#' \item{importance}{The time perceived importance of each item; an integer value between 1-100 with 100 being the most important and 1 being least} | |
#' \item{perceived}{An optional column of organization perceived importance used for point size; takes a value between 1-4;if \code{NULL} \code{importance} column will be used to generate this value} | |
#' @param legend.title A title for the legend. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(idbr) | |
library(ggplot2) | |
library(gganimate) | |
library(tweenr) | |
library(countrycode) | |
library(dplyr) | |
idb_api_key("Your API key goes here") | |
africa_fips <- countrycode(c('Nigeria', 'Uganda', 'Tanzania', 'Ghana'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
G <- list(c("MD", "DT", "NN", "VB", "VBG", "TO", "POS"), c("DT", "NN", | |
"JJ", "RB"), c("RB", "TO", "PRP"), c("VBZ", "PRP", "VBG", "RB", | |
"TO", "NN"), c("NN", "NN")) | |
G <- rep(G, 1000) | |
library(qdapTools) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(magick) | |
library(magrittr) | |
# Convert to 'ico' format | |
image_read("https://www.r-project.org/logo/Rlogo.png") %>% | |
image_scale("32x32!") %>% # remove the "!" after 32x32 to scale proportionally | |
image_write("favicon.ico", format = "ico") | |
# Favicon can also be png/gif |