Building a data frame and matrix for citation network I have a question about how to create a matrix that will take the lists defined below and make them the entries for the columns and rows. My data involves two lists: one lists originals sources (or papers) and the other lists those sources' individual citations.

The code is done in RStudio.

A sample of my original dataset looks like this:

 

 # List all the sources
 sources.vertices.levels &lt;- cit.total$Sources
 sources.vertices &lt;- (as.character(sources.vertices.levels))

 citation.edges.levels &lt;- cit.total$Citations
 citation.edges &lt;- (as.character(citation.edges.levels))

 # Break up the factors into character lists
 list.sources &lt;- levels(sources.vertices.levels)
 list.citations &lt;- levels(citation.edges.levels)


Below I have created an empty matrix (50X1497). I would like to make the row names be each individual source, and the columns be each individual citation.

Also I am lost on how to create a binary matrix that matches each individual source (from the rows) to the individual citations (to the columns). 

 # Building an aggregate matrix
 matrix.network &lt;- matrix(cit.citations,ncol=1497, nrow=50)


An example of what kind of matrix I want to do is below:
Are the 1s and 0s only to indicate that the source matches the citation? If so, try this :

library(tidyverse); library(magrittr)    
cit.total %&gt;% 
mutate(score = 1) %&gt;% # so that all 'matches' in your original data frame are tagged '1'
spread("Citations", "score", fill = 0) # each source and citation pair gets a number, 1 if the match exists, 0 if it doesn't