简体   繁体   中英

Match user input from whole csv file R shiny

Sorry for this question im newbie to R-shiny I m trying to check user input if it is available in csv file or not but it is just matching 1st row of csv file not the whole csv file column. I tried using array to check myself something like that:

output$usignin <- renderUI({
login <- read.csv("check.csv", header = TRUE, na.strings = c("","NA"))
na.omit(login)
asd = match(login$email[3], input$email)
zxc = match(login$password[3], input$password)
if((!is.na(asd)) && (!is.na(zxc))){
  h4("Correct")
}
else{
  h4("Forgot Password?")
}
})

And this thing worked but i want it to be done dynamically not statically setting array values in login$email[n] . Tried for loop didn't worked for me any other suggestions or i might did any mistake in using for loop?

It's a little tough to tell with such a small sample of the code, but this should work:

output$usignin <- renderUI({
login <- read.csv("check.csv", header = TRUE, na.strings = c("","NA"))
na.omit(login)

asd = match(input$email, login$email)
zxc = match(input$password, login$password)

test_match <- asd == zxc

if(!is.na(test_match) && test_match){
  h4("Correct")
}
else{
  h4("Forgot Password?")
}
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM