我对下面的代码片段有一个简单的问题。
library(shiny)
ui <- fluidPage(
fileInput("x", "upload file", accept = c(
"text/csv",
"text/comma-seperated-values, text/plain",
".csv")),
tableOutput("my_csv")
)
server <- function(input, output) {
csv <- reactive({
inFile <- input$x
if (is.null(inFile))
return(NULL)
df<- read.csv2(inFile$datapath, header=T)
return(df)
})
output$my_csv <- renderTable({
validate(need(!is.null(csv()),'no file yet.'))
csv()
})
}
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)
我想要的是像 get() 这样的函数来打印上传的 csv 文件的名称。在下一步中,我想创建一个列表(名为“list”),其中上传的文件作为其第一个对象和文件名。因此,如果上传的文件的名称是“squirrel.csv”并且我调用 list$squirrel.csv 我想查看该表。
我有几行data.frame,其中包含计算规则.在该字符串中我需要转换文本,如:
"{p500} * 65% >= {q600}"
Run Code Online (Sandbox Code Playgroud)
成
"{p500} * 0.65 >= {q600}"
Run Code Online (Sandbox Code Playgroud)
我是正则表达式的新手,但我认为gsub会对此有所帮助.有人可以帮忙吗?