我当前正在开发一个闪亮的App,并且无法使用从数据框中使用 sqldf()检索的值来更新textInput。 数据框看起来像这样
$select_choice_a=$_POST['select-choice-a'];
$select_choice_b=$_POST['select-choice-b'];
$select_choice_c=$_POST['select-choice-c'];
$select_choice_d=$_POST['select-choice-d'];
$select_choice_e=$_POST['select-choice-e'];
问题是当我选择电子邮件时,它应该在textInput1中显示名字,在TextInput2中显示姓氏。
使用的代码是:
Email First Last
1 abc.yyz@gmail.com abc yyz
2 vvv.rrr@gmail.com vvv rrr
任何人都可以帮助解决此问题吗?预先感谢
答案 0 :(得分:0)
您的应用代码看起来不错。这是您的应用的MWE-
library(shiny)
library(dplyr)
shinyApp(
ui = fluidPage(
selectizeInput('email', 'Enter Email ID', choices = paste0(letters, "@example.com"), options = list(
placeholder = "Please select your Email ID",
onInitialize = I('function() { this.setValue(""); }'))),
textInput('fn', ' Enter your First Name'),
textInput('ln', 'Enter your Last Name')
),
server = function(input, output, session) {
observeEvent(input$email,{
# check <- paste(input$email)
fetchvalue <- data_frame(Email = paste0(letters, "@example.com"), First = LETTERS) %>% filter(Email == input$email)
first <- fetchvalue$First
updateTextInput(session, "fn", value = first)
})
}
)
如我的评论中所述,我怀疑您的sqldf
查询错误。试试这个
fetchvalue <- sqldf(sprintf("select * from dataset where Email = '%s'", input$email))