小编Sve*_*ven的帖子

get() 闪亮上传文件的名称

我对下面的代码片段有一个简单的问题。

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 我想查看该表。

r shiny reactive

3
推荐指数
1
解决办法
2485
查看次数

在文本中将百分比转换为十进制

我有几行data.frame,其中包含计算规则.在该字符串中我需要转换文本,如:

"{p500} * 65% >= {q600}"
Run Code Online (Sandbox Code Playgroud)

"{p500} * 0.65 >= {q600}"
Run Code Online (Sandbox Code Playgroud)

我是正则表达式的新手,但我认为gsub会对此有所帮助.有人可以帮忙吗?

regex string r decimal percentage

0
推荐指数
1
解决办法
103
查看次数

标签 统计

r ×2

decimal ×1

percentage ×1

reactive ×1

regex ×1

shiny ×1

string ×1