Shawn
2022:02:27
The app returns plots of the Frequency of sexual intamacy during the years studied
library(shiny)
library(plotly)
library(readxl)
# Define UI for application that draws a histogram
shinyUI(fluidPage(
# Application title
titlePanel("Americans Sex Frequency"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
checkboxInput("show_Very_Rare", "Show/Hide Very Rare", value = F),
checkboxInput("show_Once_a_month", "Show/Hide Once a month", value = F),
checkboxInput("show_month_2_3", "Show/Hide 2-3 times a month", value = F),
checkboxInput("show_Weekly", "Show/Hide Weekly", value = F),
checkboxInput("show_week_2_3", "Show/Hide 2-3 per week", value = F),
checkboxInput("show_per_week_4", "Show/Hide 4+ per week", value = F),
),
# Show a plot of the generated distribution
mainPanel(
h3("Americans Sex Frequency"),
plotOutput("The_Plot")
)
)
))
<!–html_preserve–>
library(shiny)
library(readxl)
shinyServer(function(input, output) {
output$The_Plot <- renderPlot({
The_File <- read_excel("Americans Sex Frequency.xlsx")
The_File$Frequency <- as.factor(The_File$Frequency)
The_File$Year <- as.factor(The_File$Year)
if(input$show_Very_Rare){
Very_Rare <- as.data.frame(The_File[The_File$Frequency == "Very Rare", , ])
plot(Very_Rare$Year, Very_Rare$Count, data = Very_Rare, ylim = c(0,600))
}
if(input$show_Once_a_month){
Once_month <- as.data.frame(The_File[The_File$Frequency == "Once a month", , ])
plot(Once_month$Year, Once_month$Count, data = Once_month, ylim = c(0,600))
}
if(input$show_month_2_3){
month_2_3 <- as.data.frame(The_File[The_File$Frequency == "2-3 times a month", , ])
plot(month_2_3$Year, month_2_3$Count, data = month_2_3, ylim = c(0,600))
}
if(input$show_Weekly){
Weekly <- as.data.frame(The_File[The_File$Frequency == "Weekly", , ])
plot(Weekly$Year, Weekly$Count, data = Weekly, ylim = c(0,600))
}
if(input$show_week_2_3){
week_2_3 <- as.data.frame(The_File[The_File$Frequency == "2-3 per week", , ])
plot(week_2_3$Year, week_2_3$Count, data = week_2_3, ylim = c(0,600))
}
if(input$show_per_week_4){
week_4 <- as.data.frame(The_File[The_File$Frequency == "4+ per week", , ])
plot(week_4$Year, week_4$Count, data = week_4, ylim = c(0,600))
}
})
})
@param A tidy file consisting of the sexual frequency values in one column, the count in the next and the year in the last @return plots of the Frequency during the years studied
@description The file must have the following frequency Values - Very Rare, Once a month, 2-3 times a month, Weekly, 2-3 per week, 4+ per week, and year in the format 'yyyy'.