【发布时间】:2018-03-28 17:37:11
【问题描述】:
运行此脚本后,我创建了一个包含两列“Customers_one”和“Customers_two”的 DT 表,即 R 中的 selectInput 和 SliderInput。我从第一列中的selecInput 中选择一个名称,并将其与第二列进行比较,并在第三列中给出两者之间的百分比相似度。我的问题是,在服务器代码中的最后两个 # 语句中,我试图使表格使得当滑块指向一个值说“75”时,我只得到相似度大于或等于 75% 的行。但是,当滑块指向 100 时,这不起作用。我希望滑块指向 100 并给我只有 100% 的行,当 80 时,还有 80% 及以上的行,所以使用“85”、“90” .在 100 时,我看到了整个数据集,这就是问题所在。请帮忙。
## app.R ##
library(shiny)
library(shinydashboard)
library(stringdist)
library(RecordLinkage)
library(dplyr)
library(scales)
library(DT)
Customers_one =
c("Ashminkaul","Ashminkaul","Ashminkaur","Ashminkau","Ashmkaul","Ainkaul")
Customers_two =
c("Ashminkau","Ashminka","Ashminkaul","Ashmink","Ashminkaul","Ashminkaulb")
Customers_one = as.character(Customers_one)
Customers_two = as.character(Customers_two)
ui <- fluidPage(
titlePanel("DT table Issue"),
# Create a new Row in the UI for selectInputs
fluidRow(
column(4,
selectInput("names",
"Customer:",
c(as.character(Customers_one))),
sliderInput("slide", "Select the name with similarity %",
min = 75, max = 100,
value = 75, step = 5)
)),
# Create a new row for the table.
fluidRow(
DT::dataTableOutput("table")
)
)
server <- function(input, output) {
output$table <- DT::renderDataTable(DT::datatable({
similarity = percent(RecordLinkage::levenshteinSim(input$names,
Customers_two))
combine_total = data.frame(Customers_one,Customers_two, similarity)
combine_total
#combine_total1 = subset(combine_total, similarity >= input$slide)
#combine_total1
}))
}
shinyApp(ui, server)
【问题讨论】:
-
嗨,我希望是这样,我试过了,但我仍然无法弄清楚。如果你可以在这里运行这个脚本,你可以很容易地解决我的问题。
标签: r shiny shinydashboard dt