I'm using JS to make my R shiny app interactive. It isn't working yet and I think I have a logical error here but I cant see what it is and some help would be appreciated
so this is where I subset the data dynamically based on the user inputs which are below
POPfilteredData <- reactive({
subset(
mapanddata,
mapanddata$Sex == input$pop_gender &
mapanddata$Age.Group == input$pop_age,
select = input$pop_year
)
})
Here then are the input choices .... I haven't included them all because I'm just seeing first how it works
conditionalPanel(
condition = "input.data_category == 'population'",
selectInput(
"pop_gender",
"Gender",
c(
"Both sexes" = "Both sexes",
"Male" = "Male",
"Female" = "Female"
)
),
selectInput(
"pop_age",
"Age group",
c(
"0 - 4 years" = "0 - 4 years",
"5-10" = "5-10",
"11-15" = "11-15"
)
),
selectInput("pop_year",
"Year",
c("1980", "1981"))
)
and then this is what the data looks like, the years are observations/columns, and the age and sex are rows.
head(popdata)
Age.Group Sex Counties 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992
1 0 - 4 years Both sexes Carlow 4437 4502 4431 4340 4251 4145 4028 3904 3747 3591 3455 3339 3241
2 0 - 4 years Both sexes Cavan 5258 5319 5324 5302 5281 5235 5171 5028 4841 4655 4493 4356 4239
3 0 - 4 years Both sexes Clare 9186 9293 9211 9087 8965 8805 8617 8318 7948 7586 7267 6992 6947
4 0 - 4 years Both sexes Cork 40251 40533 40061 39407 38766 37965 37049 36009 34649 33304 32131 31137 30696
5 0 - 4 years Both sexes Donegal 13121 13349 13283 13154 13026 12842 12615 12277 11829 11384 10998 10671 10405
6 0 - 4 years Both sexes Dublin 96499 97675 96002 93907 91858 89450 86793 85216 82827 80408 78350 76674 75940
1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011
1 3139 3045 2946 2847 2797 2825 2891 2985 3117 3473 3560 3643 3716 3842 3919 4124 4246 4300 4358
2 4115 4002 3883 3763 3582 3575 3683 3842 3927 4189 4228 4260 4350 4743 4827 5063 5264 5506 6159
3 6885 6836 6773 6701 7009 7201 7315 7403 7662 7633 7798 7854 7972 8206 8358 8689 8918 9096 8923
4 30189 29749 29250 28726 28707 28795 29542 29832 30511 31115 31633 32012 32732 33618 34688 35652 37087 38443 40121
5 10121 9863 9590 9312 8864 8846 9113 9506 9718 10427 10520 10600 10819 11168 11366 11924 12399 12969 12620
6 75032 74279 73366 72376 73040 74192 75342 76163 76049 74223 75853 77977 78452 78454 81020 84213 87657 91238 93268
2012 2013 2014 2015 2016 2017 2018 2019 2020
1 4367 4278 4129 4054 4062 3968 3885 3825 3745
2 6144 6048 5877 5713 5710 5586 5480 5393 5249
3 8941 8763 8489 8249 7891 7510 7372 7320 7132
4 40503 40145 39218 37430 37541 36750 35962 35627 34956
5 12589 12395 12046 11708 10706 10471 10275 10110 9842
6 94028 92700 91611 91987 91409 89771 89179 88411 87313