appbot_topics_spreader <- function(df) {
require(tidyverse)
df <- df %>%
mutate(topics = str_to_lower(str_replace_all(topics,' ','_')),
topics = str_replace_all(topics,'&','and'),
topics = str_replace_all(topics,'-',''))
df2 <- tibble()
vals <- df %>%
distinct(id) %>%
pull()
for (i in 1:length(vals)) {
val <- vals[[i]]
z <- df %>%
filter(id == val) %>%
distinct()
z1 <- z %>%
distinct(topics) %>%
mutate(values = 1,
topics = paste('topic',topics,sep='_')) %>%
pivot_wider(names_from = topics,values_from = values)
z <- z %>%
select(-topics) %>%
distinct() %>%
bind_cols(z1)
df2 <- bind_rows(df2,z)
}
df2 <- df2 %>%
mutate_if(is.numeric,funs(ifelse(is.na(.),NA,.)))
return(df2)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.