reprex for code is the following... and dummy data is given above and stored procedure 1 is saved as sp1 and stored procedure 2 is saved as sp2 in csv format
library(plotly)
#> Loading required package: ggplot2
#>
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#>
#> last_plot
#> The following object is masked from 'package:stats':
#>
#> filter
#> The following object is masked from 'package:graphics':
#>
#> layout
library(shiny)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
rm(list=ls())
ui <-fluidPage(
titlePanel("Reactive select input boxes"),
sidebarPanel(
uiOutput("FirstChoice"),
uiOutput("SecondChoice")
),
mainPanel()
)
server = function(input, output) {
sp1<-read.csv(file = file.choose(),header = TRUE)
sp1
sp2<-read.csv(file = file.choose(),header = TRUE)
sp2
countyData = list("Raj"=c(sp1$DistrictName),"State"=c(sp2$StateName))
output$FirstChoice <- renderUI ({
selectInput(inputId = "FirstChoice",label = "Raj/State",
choices = c("Raj","State"))
})
output$SecondChoice <- renderUI ({
if (input$FirstChoice == "Raj"){lab <- "Raj"}
else if (input$FirstChoice == "State") {lab <- "State"}
else {lab <- "dependant"}
selectInput(inputId = "SecondChoice", label = lab,
choices = c(get(input$FirstChoice,countyData)))
})
}
shinyApp(ui = ui, server = server)
data on the console panel looks like this...
output-screenshot is given below
could anyone tell me why it is printing numbers instead of real value, i have tried a couple of methods like as.factor and as.character but didn't work for me, any sort of help would be great
dummy dataset:
sp1
DID | DistrictName | BlockName | CenterName | TotRaj | TotOtherState | StateCode |
---|---|---|---|---|---|---|
101 | a | null | null | 564534 | 564534 | null |
201 | b | null | null | 675645 | 765645 | null |
301 | c | null | null | 765645 | 786756 | null |
401 | d | null | null | 987656 | 764534 | null |
501 | e | null | null | 675645 | 543423 | null |
601 | f | null | null | 765434 | 231234 | null |
701 | g | null | null | 564534 | 763423 | null |
801 | h | null | null | 234565 | 567876 | null |
901 | i | null | null | 985646 | 876345 | null |
102 | j | null | null | 876754 | 453675 | null |
202 | k | null | null | 876756 | 876754 | null |
sp2
DID | DistrictName | BlockName | CenterName | TotRaj | TotOtherState | StateName | CID |
---|---|---|---|---|---|---|---|
101 | a | aaa | null | 564534 | 564534 | sdd | null |
101 | a | bbb | null | 675645 | 765645 | bdd | null |
101 | a | ccc | null | 765645 | 786756 | cdd | null |
101 | a | ddd | null | 987656 | 764534 | eff | null |
101 | a | eee | null | 675645 | 543423 | ghh | null |
101 | a | fff | null | 765434 | 231234 | sdg | null |
101 | a | ggg | null | 564534 | 763423 | ghj | null |
101 | a | hhh | null | 234565 | 567876 | lkj | null |
101 | a | iii | null | 985646 | 876345 | fgh | null |
101 | a | jjj | null | 876754 | 453675 | dfs | null |
101 | a | kkk | null | 876756 | 876754 | fgd | null |
101 | a | aaa | jkl | 4534 | 6756 | ghf | null |
101 | a | aaa | mnl | 5678 | 5645 | sdf | null |
101 | a | aaa | lkj | 6756 | 4534 | mnb | null |