[R-sig-Geo] Reshape data frame for choropleths plotting
Endri Raco
endri81 at gmail.com
Fri Jun 26 16:11:34 CEST 2015
Dear All,
I have a dataframe as below:
*name surname year sex city1 city2 city3 *
*AA AAA 2011 male 10 20 30*
*BB BBB 2011 female 25 15 25*
*CC CCC 2012 male 16 54 32*
*DD DDD 2012 female 65 41 35*
I have in my* ui. R* two selectInput controls:
* sidebarPanel(*
* selectInput('year', 'Year, choices= data$year),*
* selectInput('gender', 'Gender', choices= data$sex)*
* )*
where I want to put my selected values
In my *server. R* I have a reactive function :
* data <- reactive({*
* a <- subset(data, data$year %in% input$year)*
* a <- subset(data, data$gender %in% input$gender)*
* return(a)*
* })*
and what I want is dataframe* a* to be of form :
*name city freq*
*AA city1 10*
*AA city2 20*
AA city3 30
and this data to connect with existing .shp file with three columns:
*city long lat*
*city1 .... ....*
*city2 ... ...*
*city3 .... ......*
in order to plot map with frequencies
Can you please help
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list