--- output: html_document: css: 'whatsapp_style.css' --- ```{r whatsapp, include=TRUE, echo=FALSE, warning=FALSE,message=FALSE, results='asis'} require(shiny) require(tidyverse) file.zap <- "conversa_whatsapp.txt" zap <- read.delim(file.zap,header = FALSE) zap <- zap %>% mutate( hora = str_extract(V1,"(?<=\\[).*(?=\\])"), pessoa = str_squish(str_extract(V1,"(?<=\\])[^:]*(?=:)")), texto = str_squish(str_extract(V1,"(?<=(h|a):).*$")) ) %>% select(-V1) gerar_zap <- function(hora,pessoa,texto){ if (str_detect(texto,fixed("http://www."))){ texto <- a(href=texto,texto,target="_blank") } div(class=paste0("zap ",ifelse(pessoa == "Amiga","amiga","neale")), div(paste0(pessoa," ",hora),class="zap_pessoa"), div(texto,class="zap_texto") ) } zap_html <- div(class="zap_container",pmap(zap,gerar_zap)) zap_html ```