-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chat test.R
48 lines (41 loc) · 1.37 KB
/
Chat test.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
library(shiny)
library(shinyFiles)
# Example function to determine if a file is cleaned (this should be replaced with your actual logic)
is_file_cleaned <- function(file_path) {
# Placeholder logic to check if a file is cleaned
# Replace with actual checks, for example, if the file contains certain data
return(grepl("cleaned", file_path))
}
ui <- fluidPage(
shinyDirButton('folder', 'Select a folder', 'Please select a folder', FALSE),
tableOutput('file_table'),
textOutput('file_status')
)
server <- function(input, output, session) {
shinyDirChoose(input, 'folder', roots=c(wd='.'), filetypes=c('', 'txt'))
files <- reactive({
req(input$folder) # Ensure that input$folder is not NULL
folder_path <- paste(unlist(input$folder$path)[-1], collapse = "/")
list.files(path = folder_path)
})
output$file_table <- renderTable({
req(files())
data.frame(File = files())
})
observe({
req(files())
lapply(files(), function(file) {
observeEvent(input[[file]], {
selected_file_path <- file.path(paste(unlist(input$folder$path)[-1], collapse = "/"), file)
output$file_status <- renderText({
if (is_file_cleaned(selected_file_path)) {
paste(file, "has been cleaned.")
} else {
paste(file, "has not been cleaned.")
}
})
})
})
})
}
shinyApp(ui, server)