Chart Your Personal Network SOCL 3633 Research Methods · Lab 14 · Midwestern State University
Last week you described your own network. Today you see its shape. You load the two files you saved in Lab 13 into R, measure how connected the people in your network are, and draw the network twice: once plain, and once colored by the question that named each person. Keep this page open next to RStudio and work through the tabs in order. Submit your response sheet and the picture of your network in the Lab 14 submission on D2L by Thursday, April 22, at 11:59 p.m.
Get set up
If you do not have your files
- Copy them from your Lab 13 submission. Your submitted text on D2L contains both files. Copy the lines under
alters.csv:into a new plain text file in Notepad (Mac: TextEdit, then Format, Make Plain Text) and save it asalters.csv. Do the same for the lines underties.csv:. - Or use the practice files. Download
example_alters.csvandexample_ties.csvfrom the Week 13 module, and change the two file name lines in Step 1, as the comment in the script shows. The practice network was written for this course and does not describe real people.
If something goes wrong
| What you see | What to do |
|---|---|
| "cannot open file 'alters.csv': No such file or directory" | The file is in a different folder, or its name is different. Check the Files pane. Then click Session, Set Working Directory, To Source File Location, and run Step 1 again. |
| The file is named alters.csv.txt or alters (1).csv | Rename it so the full name is exactly alters.csv. Windows hides file endings, so saving as "alters.csv" in Notepad can add .txt. In the Save dialog, choose "All files" before you type the name. |
| "there is no package called 'igraph'" | Run Step 0 again and wait for it to finish. If it still fails, tell your instructor. |
| "Some vertex names in edge list are not listed in vertex data frame" | A name in ties.csv is spelled differently from alters.csv. Open both files in RStudio's Files pane and make the initials match exactly. |
A + sign in the Console | A parenthesis or quotation mark is missing. Press Escape in the Console, fix the line, and run it again. |
Load and measure: Steps 1 to 3
Step 1: load your two files
Put alters in the blank in nrow(____) and run it, then run nrow(ties). The first number is how many people you named; the second is how many pairs of them know each other.
Step 2: build the network
Run the graph_from_data_frame() line, then net. R joins your two files into one network: each person is a node, and each tie connects two nodes. The first line of the summary shows the number of people and ties, such as 8 8.
Step 3: how connected is your network?
Put net in the blank in edge_density(____) and run it. Then run the three lines below it, which compute the same number by hand.
Draw your network: Step 4
No blanks. Run the set.seed() and layout_with_fr() lines, then select all the lines of the plot() command and run them. The drawing appears in the Plots pane. Click Zoom to see it larger.
Then run components(net)$no, which counts the separate pieces of the network, and degree(net), which shows how many others each person is tied to.
Color and save: Steps 5 and 6
Step 5: which question named each person?
- Run the
alters$named_by <- ifelse(...)lines. They make a new column that says whether each person was named for important matters, for job help, or for both. - Put
named_byin the blank intable(alters$____)and run it. - Run the
group_colorslines and theV(net)$colorline, then theplot()andlegend()lines.
Step 6: save the colored drawing
- In the
png(line, replacelastnamewith your last name, for examplesmith_lab14_network.png. - Select every line from
png(todev.off()and run them together. Nothing appears in the Plots pane; the picture is saved in yourSOCL3633folder. - Find the file in the Files pane and click it to check that it opens.
Lab 14 response sheet
Answer in complete sentences. Then assemble your answers and paste them into the Lab 14 submission on D2L. In the same submission, upload the picture of your network. Both are due Thursday, April 22, at 11:59 p.m.
Sources
Csárdi, Gábor, and Tamás Nepusz. 2006. "The igraph Software Package for Complex Network Research." InterJournal, Complex Systems 1695. https://igraph.org
Granovetter, Mark S. 1973. "The Strength of Weak Ties." American Journal of Sociology 78(6):1360-1380.
The practice files example_alters.csv and example_ties.csv describe an invented network written for this course. They do not describe real people.