Hello,
I would like to read files from a list according to their names, i did that with str_which from the stringr package in r and it worked perfectly, but when i tried to do the same in r shiny with uploaded files, it gives nothing, but a warning .
Warning in stri_detect_regex(string, pattern, negate = negate, opts_regex = opts(pattern)) :
argument is not an atomic vector; coercing
below's the r and the rshiny code
library(data.table)
library(tidyverse)
liste <- list.files("~/s/coord",pattern="\\.xlsx$", full.names=TRUE)
coord<- lapply(liste,read_excel, skip=2,.name_repair = ~ gsub(" ", ".",.x, fixed = TRUE))
p1 <-str_which(liste, regex(" DV", fixed=T, ignore_case = T))
p2 <- str_which(liste, regex("RDV", fixed=T, ignore_case = T))
p3 <- str_which(liste, regex("Vendeur", fixed =T, ignore_case = T))
mail_dv <- rbindlist(coord[p1])
mail_rdv <- rbindlist(coord[p2])
mail_vend <- rbindlist(coord[p3])
library(shiny)
shinyApp(
ui = fluidPage(
titlePanel("Cible IPSOS"),
sidebarLayout(
sidebarPanel(
fileInput("mails",
label="Mail DV RDV & Vendeur",
multiple=TRUE,
accept=c(".xlsx"))),
mainPanel(
dataTableOutput("table")
))
),
server = function(input, output) {
output$table <- renderDataTable({
coord<- lapply(input$mails$datapath,read_excel, skip=2, .name_repair = ~ gsub(" ", ".",.x, fixed = TRUE))
p1 <- which(str_detect(input$mails$datapath, regex(" DV", fixed=T,ignore_case = T)))
p2 <- stringr::str_which(input$mails$datapath, regex("RDV",fixed=T, ignore_case = T))
p3 <- stringr::str_which(input$mails$datapath, regex("Vendeur",fixed=T, ignore_case = T))
mail_dv <- rbindlist(coord[p1])
mail_rdv <- rbindlist(coord[p2])
mail_vend <- rbindlist(coord[p3])
return(mail_dv)
}
)
}
)