0
私はVenn Diagramのセクションの1つにアップロードされたファイルの名前が付けられている(Shiny Appを作成しています)。たとえば、ある人がClientXYZ.csvファイルをアップロードすると、Venn図の1つのセクションに「ClientXYZ」という名前が付けられますShinyの変数としてアップロードされたファイルの名前を取得
これはShinyで可能ですか?
私はVenn Diagramのセクションの1つにアップロードされたファイルの名前が付けられている(Shiny Appを作成しています)。たとえば、ある人がClientXYZ.csvファイルをアップロードすると、Venn図の1つのセクションに「ClientXYZ」という名前が付けられますShinyの変数としてアップロードされたファイルの名前を取得
これはShinyで可能ですか?
再現可能な例はありませんが、入力と名前でファイルの名前を取得できます。
library(shiny)
ui <- fluidPage(
titlePanel("Grabbing my file name"),
sidebarLayout(
sidebarPanel(
fileInput('file1', 'Select your file',
accept = c(
'text/csv',
'text/comma-separated-values',
'.csv'
)
)
),
mainPanel(
textOutput("myFileName")
)
)
)
server <- function(input, output) {
file_name <- reactive({
inFile <- input$file1
if (is.null(inFile))
return(NULL)
return (stringi::stri_extract_first(str = inFile$name, regex = ".*(?=\\.)"))
})
output$myFileName <- renderText({ file_name() })
}
# Run the application
shinyApp(ui = ui, server = server)
はい、光沢があります。 'fileInput(" file1 "、" Choose CSV File "、accept = c(" text/csv "、" text /カンマ区切り値、text/plain "、" .csv ")のように、 'サーバー側では、次の' input $ file1 $ name'というファイル名を取得します。この[link](https://shiny.rstudio.com/reference/shiny/latest/fileInput.html)を参照してください。 – SBista