hi everybody,
i wrote a little shiny code where some psychotherapists can do graphical diagnosis of questionaires.
i have different timestamps (messzeitpunkte), where these questionaires were completed. in dependence of these timestamps different datasets are build (f.e):
ui <- fluidPage(
titlePanel(title = "Individualdiagnostik HSA"),
sidebarLayout(
sidebarPanel(
fileInput(inputId = "datensatz", label = "1. Datensatz laden"),
textInput(inputId = "pchiffre", label = "2. Patientenchiffre"),
selectInput(inputId = "messzeitpunkt", label = "3.Messezeitpunkt auswählen", ### Auswahl Dropdown Messzeitpunkt
multiple = FALSE, selected = NULL,
choices = c("Baseline" = "base",
"T0" = "t0",
"T6" = "t6",
"T12" = "t12",
"T18" = "t18",
"End" = "end")),
server <- function(input, output) {
datensatz_patient <- reactive({datensatz <- input$datensatz
infile <- read.csv(datensatz$datapath, header = TRUE, ";", na = -77)
patient <- input$pchiffre
subset(infile, Chiffre == patient)})
messzeitpunkt <- reactive(input$messzeitpunkt)
CTQ_dat <- reactive(
if (messzeitpunkt() == "base")
{subset(datensatz_patient(), select = c(Base_CTQ_v1:Base_CTQ_v28))}
else if (messzeitpunkt() == "end")
{subset(datensatz_patient(), select = c(End_CTQ_v1:End_CTQ_v28))} else {})
Now i need to recode some variables in my CTQ_dat().
i tried:
CTQ_dat <- reactive(if (messzeitpunkt() == "base") {sub <- subset(datensatz_patient(), select = c(Base_CTQ_v1:Base_CTQ_v28)) }
else if (messzeitpunkt() == "end") {sub <- subset(datensatz_patient(), select = c(End_CTQ_v1:End_CTQ_v28)) }
else {}
recode(sub[5], "1=5; 2=4; 3=3; 4=2; 5=1; NA=NA")
recode(sub[7], "1=5; 2=4; 3=3; 4=2; 5=1; NA=NA")
recode(sub[10],"1=5; 2=4; 3=3; 4=2; 5=1; NA=NA")
recode(sub[13],"1=5; 2=4; 3=3; 4=2; 5=1; NA=NA")
recode(sub[16],"1=5; 2=4; 3=3; 4=2; 5=1; NA=NA")
recode(sub[19],"1=5; 2=4; 3=3; 4=2; 5=1; NA=NA")
recode(sub[22],"1=5; 2=4; 3=3; 4=2; 5=1; NA=NA")
recode(sub[26],"1=5; 2=4; 3=3; 4=2; 5=1; NA=NA")
recode(sub[28],"1=5; 2=4; 3=3; 4=2; 5=1; NA=NA"),
sub)
but it didnt work.
how can i recode some variables in a reactive dataset?
please give me a hint where my mistake is....
thank you very much