data science

Calculating network structure using Bradford’s Law – R

The method, based on Kevin Crowston et al’s “Core and Periphery” paper, is explained in greater detail here.

This is the same as the other post, but it is now in a more convenient function form.

The R Function

bradford.structure <- function(df){
	df <- df[rev(order(df[2])),]
	df$pcp <- df[2]/sum(df[2])
	df$cs <- cumsum(df$pcp)

To run the function you need to first load a file with all the user names and number of posts

# user_file.txt
user        posts
jose        54
Latifah     34
Levondia    31
Laquisha    12

We load it as a normal data frame

df <- read.csv('path/to_my/user_file.txt',sep='\t')

Once it’s loaded, we use the above function ….

df_layers <- bradford.structure(df)

…and that’s it.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s