use interactive Shiny app to demonstrate your research analysis result

Shiny app is created by R studio. It can be used in creative ways to demonstrate your research results if you use R to analyze your data. Your shiny app includes server.R and ui.R. The R code that you used to run your data, can be embedded in server.R file. It may create plots, tables, network graphs, etc. You can design and program your user interface in different format, like checkbox, buttons, radio buttons, sliders, text input, etc.

Here is an example I played with on a recent study my advisor has worked on – a gender analysis of female scholars in six educational technology journals from 2004-2015.

  • used navbarPage to demonstrate two pages for including different info
  • used select box for users to select the journal
  • used tabPanel to demonstrate two different formats of barplots (created through ggplot2 in R)


copyright of the data demonstrated in this shiny app belongs to the research team, please do not use the data without permit


Many fancy examples can be found here in shiny gallery and user showcase, where you might find some inspirations. Really, it is not that hard to learn, even you don’t have any programming background, and don’t know any programming languages.

In addition, shiny app can be embedded within R presentation, to make presentation more interactive.


A social network analysis of my core discussion network

Many researchers have done studies on people’s core discussion network, the set of friends and family people turn to when discussing important matters.

I did a simple social network analysis on my core discussion network, which helped me gain an overview picture of my social network. I first made a weighted adjacency matrix to encode an egocentric network for those with whom I have discussed matters important in the last six months. In the weighted adjacency matrix, rows and columns represent different nodes, and weight ranges from 0-5. 0 means there is no connection between nodes, and 5 means the two nodes has exchanged important information. The matrix was saved in a csv file, which looks like this:

Screen Shot 2015-09-27 at 8.06.04 PM

I used R packages – network and sna  in my analysis process.

  1. The first step is to import data in R. There are two ways to import data: 1) from a google file 2) from local file

url<-“the google file URL address”
myCsv <- getURL(url)


myData<-read.csv(“local file path”)

2. The second step is convert the file into a matrix in R. (note: “row.names=1” coerces the first row into the header of the matrix)

ego<- as.matrix(read.csv(“google file URL address”, row.names=1))


ego<- as.matrix(read.csv(“local file path”, row.names=1))

3. The third step is to plot the network. I can use function gplot to draw a network plot, for example

gplot(ego, gmode=”graph”, displaylabels=TRUE, label.cex=0.8, vertex.col=”darkolivegreen”)

The plot looks like this:

Screen Shot 2015-09-27 at 8.19.03 PM

4. The last step is to customize the network. I want to present different groups with different color, and edge width represents the weight between two nodes. This process is a little complicated.

# add an attribute edgeweight to the network

MyNetwork <- network(ego, directed=FALSE, edge.attrnames=”edgeweight”)

# set values to the edgeweight attribute

set.edge.attribute(MyNetwork2, “edgeweight”, value=c(1,2,3,4,5))

# set nodecolors
nodeColors = c(“goldenrod3″,”steelblue1″,”steelblue1″,”steelblue1”,  “darkgreen”,”darkgreen”, “darkgreen”,”firebrick”,”firebrick”, “firebrick”,”firebrick”,”darkslateblue”,”darkslateblue”, “darkslateblue”,”blue”,”blue”,”blue”)

# use function plot to draw the network
plot(MyNetwork,displaylabels=TRUE, label.cex=0.5,edge.lwd=”edgeweight”,vertex.col=nodeColors)

Finally, my core discussion network (ego network) looks like this:

Screen Shot 2015-09-27 at 8.25.10 PM

I didn’t record all my important connections in the matrix. But based on the above analysis, it is demonstrated that in my core discussion network, the friendship, coworker relationship, and kinship are apparent in my personal network. Alters in these four different networks are closely tied to each other within each network, but there is no relationships between or among these four different networks. For instance, my dad, mom, and sister are closely tied to each other in the kinship network, but they are not tied to my friendship network, or coworker network. A unique network is the partner network, they are not linked to each other at all.