#This R script provides a typical example of the first steps used to work with a dataset #set the working directory setwd ("/Users/jenschellinck/Documents/sysabee/partnerships/DataActionLab/open_data_lab/R-Showcase-SNA") #read in the dataset allphonedata <- read.csv("nodobo_dataset_igraphdlab.csv",colClasses=c(user="character", other="character",direction="character",duration="numeric",timestamp="character")) #create a new dataset that is a subset of the original dataset, to focus on data of interest phonedata <- allphonedata[allphonedata$direction=="Outgoing",-3] phonedata <- phonedata[phonedata$duration>=1000,] #finish setting up the dataset within R in the way you like colnames(phonedata)[colnames(phonedata)=="user"] <- "caller" colnames(phonedata)[colnames(phonedata)=="other"] <- "callee" #create some helper data structures id_list <- unique(phonedata$caller) #load an R package that you want to use to analyze the data library(igraph) #create a new R object using the original data, that will be used when analyzing the data phonegraph <- graph_from_data_frame(phonedata, directed = TRUE, vertices = NULL) E(phonegraph)$weight <- 1 #carry out some operation on the new object phonegraphcp <- simplify(phonegraph, edge.attr.comb=list(weight="sum")) #visualize the result plot( phonegraph, vertex.size=0, vertex.label=NA, edge.arrow.size=0 )