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
simulate_pack <- function(...) { | |
very_rare_pool <- c(paste0("sr", 1:n_super_rare), | |
paste0("ur", 1:n_ultra_rare), | |
paste0("secr", 1:n_secret_rare)) | |
very_rare_prob_vec <- c(rep(prob_super_rare / n_super_rare, n_super_rare), | |
rep(prob_ultra_rare / n_ultra_rare, n_ultra_rare), | |
rep(prob_secret_rare / n_secret_rare, n_secret_rare)) | |
commons <- sample(paste0("c", 1:n_commons), 7, replace = T) |
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
get_expected_events <- function(x) { | |
#' take in a number of elements in a set | |
#' and a probability | |
out <- x * log(x) + 0.577 * x + 0.5 | |
return(out) | |
} | |
n_commons <- 48 | |
n_rare <- 20 | |
n_super_rare <- 12 |
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
# Compiled source # | |
################### | |
*.com | |
*.class | |
*.dll | |
*.exe | |
*.o | |
*.so | |
# Packages # |
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
vocab <- readxl::read_excel("insert_your_excel.xlsx") %>% | |
tidytext::unnest_tokens(word, text) %>% | |
dplyr::count(word, sort = TRUE) %>% | |
anti_join(stopwords::stop_words) %>% | |
dplyr::mutate(french_text = googleLanguageR::gl_translate(word, target = "fr", source = "en")$translatedText) | |
bigram_constructions <- readxl::read_excel("insert_your_excel.xlsx") %>% | |
unnest_tokens(bigram, text) %>% | |
count(bigram, sort = TRUE) %>% | |
mutate(french_text = googleLanguageR::gl_translate(bigram, target = "fr", source = "en")$translatedText) |
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
#functions.R | |
create_plot <- function(data) { | |
ggplot(data) + | |
geom_histogram(aes(x = hp_per_cyl)) + | |
theme_bw() | |
} | |
validate_data <- function(data) { | |
rules <- validator(hp > 0, |
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
# _targets.R | |
## installs and loads libraries | |
pacman::p_load(targets, tidyverse, validate) | |
source("R/functions.R") | |
options(tidyverse.quiet = TRUE) | |
#sets package(s) globally for all subsequent targets | |
tar_option_set(packages = c("tidyverse")) | |
list( | |
#record state of R environment |
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
SAFFRONres <- SAFFRON(sample.df) | |
new_data <- SAFFRONres%>% | |
mutate(index = row_number(), | |
SAFFRON = log(alphai), | |
Bonferroni = log(0.05/index), | |
Unadjusted = rep(log(0.05), nrow(.))) %>% | |
pivot_longer(cols = c(SAFFRON, Bonferroni, Unadjusted), | |
names_to = "adjustment", | |
values_to = "alpha") |
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
sample.df <- data.frame( | |
id = c('A15432', 'B90969', 'C18705', 'B49731', 'E99902', | |
'C38292', 'A30619', 'D46627', 'E29198', 'A41418', | |
'D51456', 'C88669', 'E03673', 'A63155', 'B66033'), | |
pval = c(2.90e-08, 0.06743, 0.01514, 0.08174, 0.00171, | |
3.60e-05, 0.79149, 0.27201, 0.28295, 7.59e-08, | |
0.69274, 0.30443, 0.00136, 0.72342, 0.54757), | |
batch = c(rep(1,5), rep(2,6), rep(3,4))) |
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
server <- function(input, output, session) { | |
#reset | |
observeEvent(input$reset, { | |
updateSelectInput(session, 'cyl') | |
updateNumericInput(session, 'disp', value = 100) | |
updateNumericInput(session, 'hp', value = 100) | |
updateNumericInput(session, "drat", value = 3) | |
updateNumericInput(session, "wt", value = 3) | |
updateNumericInput(session, "qsec", value = 20) |
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
body <- dashboardBody( | |
h2("The predicted miles per gallon is: "), | |
h3(verbatimTextOutput("pred", placeholder = T)), | |
tags$head(tags$style("#pred{color: black; | |
font-size: 20px; | |
font-family: Source Sans Pro | |
}")), | |
fluidRow( | |
infoBox( | |
"What", "is this model for?", icon = icon("line-chart"), |
NewerOlder