I'm trying to write a Shiny App in R that let's users see their individual survey results based on a participant code. Unfortunately the participant code starts with a number (e.g. 01ABAB01) so renaming duplicate rows with make.names will also result in an X in front of all the codes (e.g. X01ABAB0). Now the codes are needed for participants to adress their data so they'd ideally be exactly what participants originally typed in (I could in theory tell participants to put an X in front of their code, but that wouldn't be exactly elegant). So I'm looking for a way to either avoid the renaming (while still getting unique rownames), to undo the renaming or to have users input the original Code but still have shiny call the correct row. I tried Data[paste("X",input$Code), "SP03_01"] and some variations of that but it would result in "Your result is NA".
Data <- read.csv("Daten2.csv", header= TRUE, sep = ";", na.strings=c("",".","NA"), skipNul = TRUE)
rownames (Data)= make.names (Daten$IN04_05, unique = TRUE)
ui <- fluidPage(
titlePanel("Your results"),
sidebarLayout(
sidebarPanel(
textInput(inputId = "Code", label= "Please enter your code", placeholder= "z.B. 01ABAB01"),
actionButton (inputId = "Button", label = "Show my results"),
mainPanel(textOutput(outputId = "Example"))
)
)
server<-function(input,output){
output$Example<-eventReactive(
input$Button, {print(paste("Your result is ", Data[input$Code, "SP03_01"]))}
)
}
shinyApp(ui=ui, server=server)
Any ideas? I've been truly stuck with this bit for some reason :P