This exercise brings together what we have learned about networks so far, and builds on some of the skills from Practice Exercise # 3. You will be creating your own notebook from scratch, calling data, manipulating that data, and analyzing it. Please submit the zipped folder containing the notebook and the 7 .png images you create via this Lyceum link (section A) (section B) by the start of class on November 13th
- Create a new folder. Name it PE5 (do not include your name). You will be downloading, zipping, and uploading this folder.
- Create a new notebook in this new folder. Name it DSC_104_PE5 (do not include your name – I will grade anonymously and then return your notebooks)
- Title your notebook. Make your first cell into a markdown cell (hit escape and then m) and then enter one hashtag – this makes the cell into a title cell. Write a placeholder title (you’ll come back at the end and change the title). Run the cell.
- Title your sections. Repeat the steps above for seven new cells but use two hashtags (this creates smaller title text). Name them: Analysis, Packages, Calling Data, Constructing Networks, Analyzing Networks, Visualizing Networks, Text networks
- Install the package “igraph”
- Load the package “igraph”
- Download the .csv file people_family.csv, and enter a 1 in each cell where the last name of the person in the row matches the last name in the column. (This assumes that families are related by both marriage and birth)
- Save that file and upload it to your notebook environment
- Load people_family.csv as a matrix
- Load people_work.csv as a matrix (use the link from the Network Analysis notebook)
- Load the attributes data file
- Convert each matrix into a matrix that shows connections between people (use the code from the Network Analysis notebook)
- Create a new variable, and add the matrixes together (just use a +)
- Set the diagonals of this new matrix to NA
- Create a network graph object based on this new matrix
- Set the diagonals of your people_work matrix to NA
- Create a network graph object based on your people_work matrix
- Set the diagonals of your people_family matrix to NA
- Create a network graph object based on your people_family matrix
- Calculate the betweenness for each network. Make sure that you assign names to your statistics using V().
- Make note of differences among your three networks
- Calculate the centrality for each network. Make sure that you assign names to your statistics using V().
- Make note of differences among your three networks.
- Visualize each network (use the code from the Network Analysis notebook). Save each into a different .png file
- Look at each network, make note of differences
- Add color according to country of origin. Instead of using names for colors, go to http://colorbrewer2.org/, set the number of data classes to 3 (one for each country – USA, Canada and Greece) and set the nature of your data to qualitative. Pick one of the color schemes that you like, and enter the hex code (it will look something like #7fc97f) in place of “red”, “blue” and “green” in the Network Analysis notebook.
- We are going to add one more dimension, which is strength of connection. Create a new variable that will capture the strength of the relationship between two nodes (in network parlance, this is known as edge.weight). Use the code below, but put the name of the graph object that holds the network that shows both family and work connections:
YOURNEWVARIABLE <- get.edge.attribute(GRAPH-REPLACE-THIS-TEXT, "weight)
- Now, run the code that makes your network visualization again, but replace
edge.width = 0.25
edge.width = YOURNEWVARIABLE
- Make note of any changes.
Cleaning your notebook
- Before you submit your notebook, go back and delete cells with extraneous information or attempts that did not work.
- If you feel like you need to explain decisions or flag problem points, do so now.
- Write an introduction that explains any insights that you gained from your data, and any new questions that your visualizations raised. Illustrate your insights using your images. You can insert images into your notebook using the following syntax (replace image.png with the file name of the image you want to insert):
![the title for your image](image.png)
- Create a witty and/or informative title for your notebook.