Skip to content

Commit bfe7f5d

Browse files
author
Ahmed Hussnain
committed
adding r-shiny-app
1 parent adc9dd9 commit bfe7f5d

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

r-shiny-app/server.R

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,24 @@ freqfunc <- function(x, n){
77

88
function(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
}

r-shiny-app/ui.R

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
library(shiny)
22
library(ggplot2)
33

4-
pageWithSidebar(
4+
fluidPage(
55
headerPanel('Stackoverflow Survey Data'),
66
sidebarPanel(
77
selectInput('country', 'Select Country', choices = df$Country, selected = "Pakistan"),
88
selectInput('question', 'Select Question',choices = c('HaveWorkedLanguage','WantWorkLanguage','HaveWorkedFramework','WantWorkFramework','HaveWorkedPlatform','WantWorkPlatform'),selected='HaveWorkedLanguage'),
9-
width = 3
10-
#numericInput('clusters', 'Cluster count', 3,
11-
# min = 1, max = 9)
9+
width = 4
1210
),
1311
mainPanel(
1412
plotOutput('plot1',width = "100%", height = "300px")

0 commit comments

Comments
 (0)