2023-03-02

Synopsis

This App tracks course enrollments in Languages other than English in US degree-granting postsecondary institutions from 1965 to 2016.

Two functions in the App:

  • Year: Select a year to check the language course enrollments in that year.
  • Language: Select a language to check the enrollment trends of that language.

Try the App now.

The reproducible documents are in this Github repo.

Data

Data Source: National Center for Education Statistics

Data was pre-processed before working on this App.

Here is the first 10 rows of the final data:

   language year enrollment
1       All 1965    1034651
2    Arabic 1965        911
3   Chinese 1965       3359
4    French 1965     371747
5    German 1965     213909
6     Greek 1965      19495
7    Hebrew 1965       8093
8   Italian 1965      22950
9  Japanese 1965       3505
10   Korean 1965         82

Code of ui.R

        shinyUI(fluidPage(
                titlePanel("Language Course Enrollments in US (1965--2016)"),
                sidebarLayout(
                        sidebarPanel(
                                p("This App tracks course enrollments in Languages other than English in US degree-granting 
                                postsecondary institutions from 1965 to 2016. You can select a year to check the language course 
                                   enrollments in that year from 'Enrollments in the Year' tab, or select a language to check the 
                                   enrollment trends of that language in 'Enrollments Trend' tab."),
                                tags$a(href="https://nces.ed.gov/programs/digest/d19/tables/dt19_311.70.asp", 
                                       "Data Source: National Center for Education Statistics", target="_blank"),
                                br(),
                                selectInput(inputId="year", label=strong("Year"),
                                            choices=unique(enrollments$year), selected="1965"),
                                h6("* Select a year to check the language courses enrollments in that year."), 
                                selectInput(inputId="language", label=strong("Language Course"), 
                                            choices=unique(enrollments$language), selected="Chinese"),
                                h6("* Select a language to check the enrollment trends of that language."),
                                h6("* Greek means Ancient Greek."),
                                h6("* Chinese includes Cantonese and Mandarin.")),
                        mainPanel(
                                tabsetPanel(type="tabs",
                                            tabPanel("Enrollments in the Year", br(), textOutput("year"),
                                                     plotOutput("barplot")),
                                            tabPanel("Enrollments Trend", br(), textOutput("language"), 
                                                     plotOutput("trendplot")))))))

Language Course Enrollments in US (1965--2016)

This App tracks course enrollments in Languages other than English in US degree-granting postsecondary institutions from 1965 to 2016. You can select a year to check the language course enrollments in that year from 'Enrollments in the Year' tab, or select a language to check the enrollment trends of that language in 'Enrollments Trend' tab.

Data Source: National Center for Education Statistics
* Select a year to check the language courses enrollments in that year.
* Select a language to check the enrollment trends of that language.
* Greek means Ancient Greek.
* Chinese includes Cantonese and Mandarin.
  • Enrollments in the Year
  • Enrollments Trend


Code of server.R

        shinyServer(
                function(input, output, session){
                        output$year <- renderText({paste("Enrollments in the year", input$year)})
                        output$barplot <- renderPlot({
                           year_data <- reactive({
                               enrollments %>% 
                                     filter(year == input$year & language != "All" & language != "Other languages") %>% 
                                     mutate(language=ifelse(language=="American Sign Language", "ASL", language)) })
                           percents <- reactive({percent(year_data()$enrollment/sum(year_data()$enrollment), accuracy=0.01)})
                           ggplot(data=year_data(), aes(x=reorder(language, -enrollment), y=enrollment))+
                                        geom_bar(stat="identity", fill="salmon", col="white")+
                                        labs(x="Language", y="Enrollments", caption="* ASL: American Sign Language")+
                                        coord_cartesian(ylim=c(0,880000))+
                                        scale_y_continuous(labels = comma)+
                                        geom_label(aes(label=enrollment), vjust=-0.3)+
                                        geom_text(aes(label=percents()), vjust=1.2, size=4, col="white")+
                                        theme(plot.caption = element_text(hjust = 0, size=12))})
                        output$language <- renderText({paste("Enrollments Trend of", input$language)})
                        output$trendplot <- renderPlot({
                                lang_data <- reactive({enrollments[enrollments$language == input$language,]})
                                ggplot(data = lang_data(), aes(x=factor(year), y=enrollment))+
                                        geom_bar(stat="identity", fill="lightgreen")+
                                        labs(x="Year", y="Enrollments")+
                                        geom_label(aes(label=enrollment), vjust=1.5)})})

* Code is simplified a bit for fitting in this slide.