@@ -7,37 +7,24 @@ freqfunc <- function(x, n){
77
88function (input , output , session ) {
99
10- # Combine the selected variables into a new data frame
10+
1111 selectedData <- reactive({
1212 subset(df , Country == input $ country , select = c(" Country" ,input $ question ))
13- # iris[, c(input$xcol, input$ycol)]
13+
1414 })
1515
16- # clusters <- reactive({
17- # kmeans(selectedData(), input$clusters)
18- # })
1916
2017 output $ plot1 <- renderPlot({
21- # palette(c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3",
22- # "#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999"))
18+
2319 feature_data = selectedData()
2420 colnames(feature_data ) = c(" Country" ," question" )
25-
26- # feature_data = feature_data[complete.cases(feature_data), ]
27- # question = trimws(as.character(feature_data$question),which = c("both", "left", "right"))
28- # question <- strsplit(question, ";")
29- # sel_df = head(data.frame(table(unlist(strsplit(tolower(question), ";")))),5)
21+
3022 sel_df = as.data.frame(freqfunc(feature_data $ question , 10 ))
3123 ggplot(data = sel_df , aes(x = sel_df $ Var1 , y = sel_df $ Freq , fill = factor (sel_df $ Var1 ))) +
3224 geom_bar(stat = " identity" ) +
33- xlab(" Responndants choices" ) +
25+ xlab(" Respondents choices" ) +
3426 ylab(" Number of Resonpses" ) +
3527 theme(legend.position = " none" )
36- # par(mar = c(5.1, 4.1, 0, 1))
37- # plot(selectedData(),
38- # col = clusters()$cluster,
39- # pch = 20, cex = 3)
40- # points(clusters()$centers, pch = 4, cex = 4, lwd = 4)
4128 })
4229
4330}
0 commit comments