在運行此腳本時,我創建了一個DT表,其中包含兩列「Customers_one」和「Customers_two」,它們是R閃亮式中的selectInput和SliderInput。我從第一列中選擇selecInput
的名稱,並將其與第二列進行比較,並在第三列中給出兩者之間的百分比相似性。我的問題是,在服務器代碼中的最後兩個#語句中,我試圖製作表格,以便當滑塊指向值「75」時,我得到的行只有相似度大於或等於75%。但是,當滑塊指向100時,這不起作用。我希望滑塊指向100,並且只給出100%的行,同樣當80時,80%及以上的行,以及「85」,「90」 。在100處,我看到整個數據集,這就是問題所在。請幫忙。SliderInput與R閃亮表中的表問題
## 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閃存表100](https://stackoverflow.com/questions/46766286/slider-not-giving-proper-value-when-pointed-at- 100-in-r-shiny-table) –
嗨,我希望是的,我試過了,但我仍然無法弄清楚。如果你可以在這裏運行這個腳本,你可以很容易地得到我的問題。 –