# Packages library(sfi) library(kmodR) library(directlabels) library(webshot) library(ggplot2) library(dplyr) library(ggrepel) library(plotly) library(ggiraph) library(scales) library(tidyverse) library(knitr) library(Hmisc) library(RColorBrewer) library(extrafont) library(kableExtra) library(grid) # webshot::install_phantomjs() loadfonts() ## Global options options(max.print="75") opts_chunk$set(echo=FALSE, cache=FALSE, prompt=FALSE, tidy=TRUE, comment=NA, message=FALSE, warning=FALSE, dpi = 300, # dev = "cairo_pdf", dev = c("png", "cairo_pdf"), fig.pos="!h", fig.path = 'figures/') opts_knit$set(width=75) options(xtable.comment = FALSE)
\newpage
data <- all_data$chenvoice$f1 # make correlation plot g1 <-ggplot(data, aes(zresponse1, zresponse2)) + geom_point(size = 2) + geom_smooth(method = 'lm', se = TRUE, linetype = 0) + labs(title = 'Correlation plot', x = '1 Mean response', y = '0 Mean response', caption = 'Std error estimated with a linear model') + theme_sfi() + theme(axis.text=element_text(size = 10, hjust = 1), plot.title = element_text(size =12)) + facet_wrap(~qtype, nrow = 2) g1
data <- all_data$chenvoice$f2 data <- as.data.frame(rbind(names(data), data)) names(data) <- c('var1', 'var2', 'value') # recode data$var1 <- gsub('X1', 'Both', data$var1) data$var2 <- gsub('1', 'Intercept', data$var2) # restructure data$var1 <- as.factor(data$var1) data$var2 <- as.factor(data$var2) data$value <- as.numeric(data$value) data$jitter_value <- ave(as.numeric(data$value), data$value, FUN = function(x) x + rnorm(length(x), sd = .3)) # plot g1 <- ggplot(data, aes(reorder(var2, -jitter_value), jitter_value, group = var1, col = var1)) + geom_segment(aes(x=reorder(var2, jitter_value), xend=var2, y=0, yend=jitter_value), size = 1, alpha = 0.5, position = 'stack') + geom_point(size= 2, alpha = 1, aes(color = var1)) + scale_color_manual(name='', values = c('#AEAEAE', '#181818','#6C6C6C')) + labs(title = 'Audio features', subtitle = 'feature importance (jittered by importance)', x = 'Names of features', y = 'Importance score for features') + coord_flip()+ theme_sfi(gM = FALSE) + theme(axis.text=element_text(size = 10, hjust = 1), axis.text.x = element_text(), plot.title = element_text(size =12)) g1
g1 <- ggplot(data, aes(reorder(var2, -value), value, group = var1)) + geom_point(size= 2, alpha = 1, position = position_dodge(0.5), aes(color = var1)) + scale_color_manual(name='', values = c('#AEAEAE', '#181818','#6C6C6C')) + geom_linerange(aes(ymin =0 , ymax =value, color = var1), size = 0.5, position = position_dodge(0.5)) + labs(title = 'Audio features', subtitle = 'feature importance (jittered by petitioner and respondent)', x = 'Names of features', y = 'Importance score for features') + coord_flip()+ theme_sfi(gM = FALSE) + theme(axis.text=element_text(size = 10, hjust = 1), axis.text.x = element_text(), plot.title = element_text(size =12)) g1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.