ReadMe -- Asian Enrollments

Last update: 12/9/18
Overview
The R-code is contained in four files: master1.R, master2.R, master3.R, and master4.R that should be run in sequential order. Each master*.R file has three sections. 
  • Section A contains commands that read data and load library files. These commands should be sourced/executed sequentially
  • Section B contains locally defined functions that must be sourced before the commands in Section C are executed
  • Section C contains commands that invoke the functions that create the required objects when the commands are executed

master1.R
  • The commands in Section A read the IPEDS-raw.csv file into a tibble called dtIPEDS_raw, and read IPEDS-raw-others.csv into a tibble called IPEDS_Others_raw
  • The commands in Section C invoke functions in Section B that rename the IPEDS variables to short, user-friendly names, and join the two tibbles into one tibble via a SQL inner join. The resulting tibble, tableRaceOthers_0 has 21 rows and over 250 columns
  • The remaining commands in Section C trigger the creation of 21 list objects, one for each institution, that contain data for the Class of 2016. In other words, list objects called "Harvard", "Yale", "Stanford", etc are created  
  • A preliminary version of a table that contains enrollment data for all 21 institutions for the Class of 2019 is also created. 
  • The last commands in Section C save the 21 institution lists and the enrollment tibble into the master1.rda file

master2.R
  • The commands and functions in this file add one table and two charts to each institution's list
  • As usual, the commands in Section A should be sourced/executed that load library files and read the objects saved in master1.rda back into memory; then the locally defined functions in Section B should be sourced; finally the commands in Section C should be sourced/executed.
  • Section C creates a master list called "listInstitutions" that contain the 21 named list objects, e.g., "Harvard", "Yale", etc
  • The last command in Section C saves "listInstitutions" into the master2.rda file; it also saves the draft of the enrollment table.

master3.R

  • The commands and functions in this file create two charts and one table that summarize data about the Class of 2016, but splits the table into two sections in to enable it to fit within the narrow margins of the Webpages on the DLL's blog where the report is published
  • The final version of the enrollment table for the Class of 2015 is also created and split into two parts so it will fit within the margins of the DLL's blog
  • These functions also create the "HarvardTech" table
  • The last commands in Section C save the summary charts, summary tables, enrollment table, HarvardTech, and listInstitutions (unchanged) into the master3.RDA file

master4.R
  • The commands and functions in this file load listInstitutions and the summary charts and tables
  • The code loops through listInstitutions to extract the charts and table, printing the two charts to *.jpg files and the table to a *.html file
  • Similarly, the code prints the two summary charts to *.jpg files and the summary table to a *.html file
  • And the code prints the enrollment tables to *.html files
  • The charts can be added to Webpages via the usual copy and embed functions that for graphics. 
  • Unfortunately, the tables require a manual cut and paste process that is described in the final section of this ReadMe

Copying and pasting tables

  • Up until now this ReadMe has implicitly assumed that the user is deploying an unspecified IDE for R. The following instructions explicitly assume that the IDE is R Studio
  • Select an .html file in the "Files" pane ==> R Studio will display a menu with two choices "Open in Editor" and "View in Browser" ==> Select "Open in Editor
  • R Studio will then display the .html file in the "Source" pane
  • Copy the html from the opening tag to the closing
    tag
  • Paste this html into the desired location on your WebPage
  • If you want to display your table using the striped white and light-skyblue bars shown on the DLL's pages copy and paste the following CSS code to a position just before the opening tag for the pasted table from
  • If you copy and paste more than one table onto a Webpage, you only need one copy of the CSS code, before the first table.
 Light sky-blue  
   
 <style>  
   tbody tr:nth-child(odd){  
   background-color: #CAEEFFFF;  
  }  
 </style>  

No comments:

Post a Comment

Thank you!!! Your comments and suggestions will be greatly appreciated ... :-)