Styling

Once we have a complete working application, it is time for some styling with CSS. In the following example, just some fonts are changed. It is always good, when possible, to control the styles with CSS. There are some widgets, such as plot outputs that are not so easy to handle as the tags assignment is restricted.

In the following CSS, saved as style.css, some of the texts are styled as follows:

.title {
  font-size: 18px;
  font-weight: bold;
}
h1 {
  font-style: italic;
  font-family: impact;
}

As it was explained in Chapter 8, Shiny and HTML/JavaScript, CSS stylesheets can be included with an includeCSS() statement inside UI.R:

# Starting line
shinyUI(fluidPage(
 
 #CSS styling
 includeCSS("PATH_to_CSS_file/style.css"),
 # Application title
 titlePanel("Adult Dataset"),

Discovering insights in the application

With an application ready to use, it is always rewarding to find out that it fulfills its purpose. In this case, it would be to discover insights visually from the data.

The following screenshot is very illustrative about the educational possibilities in the past. As it may be noted, the Male and Female lines are very similar until HS-grad. In fact, the percentage of females that reached this educational state is slightly higher. But after this, the trend is drastically reverse, and it is the Male line that is clearly above the Female one. Although further research should be done in order to figure out the causes of this phenomenon (the reader can make their own hypothesis), it is clear that the possibilities of studying were not the same ones:

Discovering insights in the application

The age distribution by gender presents curious results as well. It seems that, at least in the sample collected in this dataset, the distribution by ages is not similar; women's curve has a peak between 18 to 25, while men have are concentrated on the 30 to 45 segment approximately:

Discovering insights in the application

These are only some examples of what a web application with suitable data visualizations can tell us from the data source that we are analyzing. In this sense, Shiny and R are great allies because they can take the integration of data analysis and data presentation to a whole new level; an almost limitless backend built on one of the most important programming languages in data science with an entire intuitive, user-friendly and extensible framework. In summary, anything that can be programmed can be coded in R and everything that can be displayed in a web browser can be produced in Shiny.

Shiny is not just another way of creating web applications, but it is also an open source-based key with practically no restrictions when it comes to communicating things with data.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset