---
title: 'SOCI424/624: Affiliation'
author: '(anonymous for peer evaluation)'
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
# load the 'igraph' package
library(igraph)
```


## Part 1: Get the data

### Suffragettes
Todays' we'll use a historical dataset of the arrests of British suffragettes (principally women activists fighting for the right to vote). This data was collected by Gemma Edwards and Nick Crossley as part of a larger study of the movement, and is available in full from the [UCINET data repository online](https://sites.google.com/site/ucinetsoftware/datasets/covert-networks/suffragettes). The specific data we will use is a bipartite network relating suffragettes to arrest events (dates and locations), and is available at <https://soci424.netlify.app/data/suffragette_arrests.csv>.

-   *Use R's `read.csv()` and `as.matrix()` functions to load the data and convert it to a `matrix` object. Store this as variable named `amat`. Make sure that the row names (`rownames()`) and column names (`colnames`) of the matrix correspond to the people and events in the original data. (Note that by default R will add an 'X' to the front of any column names that start with a number. This is fine for this worksheet)*

```{r 1_1}
# (your code here)
```

-   *Examine `amat` in R. How many rows and columns does it have? What do the rows and columns represent?*

```{r 1_2}
# (your code here)
```

## Part 2: Bipartite network

In this section, you will create a bipartite (affiliation) network to explore the survey results.

-   *Use `graph_from_incidence_matrix()` to create a bipartite network from the affiliation matrix, and store the resulting graph to a variable named `anet`. In igraph, a bipartite network is simply a network containing a vertex for each of the suffragettes (rows) and each of the arrest dates (columns). The network has a special vertex attributes called `type` that is either `TRUE` (meaning that vertex represents an arrest event) or `FALSE` (meaning that vertex represents a suffragette). Plot the resulting network, adjusting visual characteristics to be able to see some of the structure of the network. You don't need to do too much for this visualization, just make it easier to 'read' than the default.*

```{r 2_1, fig.width=10, fig.height=10}
# (your code here)
```

-   *Use the data in the `type` vertex attribute to set the `color` attribute differently for suffragettes and events Then, plot the network you just created again. Do you see any obvious patterns? Are there any arrest events that tend to be 'clustered' together (i.e. the same people tended to be arrested at them)?*

```{r 2_2, fig.width=10, fig.height=10}
# (your code here)
```

-   *The `bipartite_projection()` function in igraph _projects_ the two-mode person–event network into a person–person network and an event-event network. This output is represented as a list with two named items: "proj1" and "proj2". Create two new networks named `suffnet` and `eventnet`, representing each of these projections (you will use the `$` notation to access the different list items).*

```{r 2_3}
# (your code here)
```

-   *Plot each of the projections from the previous step, adjusting visual parameters if necessary. Note that the projections create a new edge attribute: "weight" that measures the number of co-occurrences -- you should incorporate this. What kinds of interpersonal structures can you see? What kind of structure can you infer between the arrest events based on the projections?*

```{r 2_4}
# (your code here)
```

## Part 3: Network evolution

The arrests in the data take place between June 21, 1906 and October 23, 1920 (you can see this from the event names). Gemmma Edwards describes a change in tactics for the suffragette movement in Britain over this time period, moving from more symbolic acts like hunger strikes in the beginning, to more 'militant' strategies like arson and bombings in the period from 1913-14. This part of the worksheet will try to identify structural changes in the network that correspond with this change

-   *Create two affiliation matrices, one for all events that occur before 1913, and another that contains all events from 1913 onward. The columns in the dataset are temporally ordered, so you can create the matrices just by locating the last column index of 1912 and the first column index of 1913 (you can identify this by reading through the names manually). Use these matrices to create bipartite networks for the two time periods. _BONUS for more advanced R users: create the two matrices without manually identifying the 1912–1913 cutoff, instead parsing the event names._*

```{r 3_1}
# (your code here)
```

- *Use R to remove the two networks' 'isolates' (sufragettes who were not arrested at any of the relevant events). Cutting the network into two time periods is bound to create many such isolates, e.g. for people who joined the movement late or left the movement early. You can use the `delete_vertices()` function to do this, which takes as its arguments an existing network and a vertex sequence, and returns a new network with the indicated vertices removed. How many suffragettes does each network contain once the isolates are removed?*

```{r 3_2}
# (your code here)
```

- *Create person-person and event-event projections for the pre-1913 and post-1913 bipartite networks. Focussing first on the person-person networks, how many suffragettes are present in both networks (i.e. how many people were arrested in both time periods -- the `intersection()` function may be helpful here)? Plotting the networks, do you see a different structure? Does the comparison suggest anything about the proposed tactical shift in 1913?*

```{r 3_3}
# (your code here)
```

- *Considering the event-event network, what kinds of structural changes to this network might a shift to more militant tactics entail? Plot the networks (and potentially calculate other network statistics). Do you see the kinds of changes you hypothesized in the network?*

```{r 3_4}
# (your code here)
```



# References

Edwards, Gemma, and Nick Crossley. "Measures and meanings: exploring the ego-net of Helen Kirkpatrick Watts, militant suffragette." Methodological Innovations Online 4.1 (2009): 37-61. 

Edwards, Gemma. "Infectious innovations? The diffusion of tactical innovation in social movement networks, the case of suffragette militancy." Social Movement Studies 13.1 (2014): 48-69.

Edwards, Gemma. Social Movements and Protest. Cambridge University Press, 2014.  Crossley, Nick, et al. "Covert social movement networks and the secrecy-efficiency trade off: The case of the UK suffragettes (1906–1914)." Social Networks 34.4 (2012): 634-644. 