Closed beeshot closed 4 years ago
# install lib if (!suppressWarnings(require(rjson))) install.packages("rjson") if (!suppressWarnings(require(igraph))) install.packages("igraph") if (!suppressWarnings(require(dplyr))) install.packages("dplyr") if (!suppressWarnings(require(jsonlite))) install.packages("jsonlite") library("rjson") library("igraph") library("dplyr") library("jsonlite") #import json file from local machine json_file <- "~/blockchain/rstudio/trans.json" json_data <- jsonlite::fromJSON( json_file ) summary(json_data) transaction <- data.frame( from=c (json_data$fromAddress), to=c (json_data$toAddress) ) network <- graph_from_data_frame(d=transaction, directed=F) deg <- degree(network, mode="all") plot(network, vertex.size=deg*6, vertex.color=rgb(0.1,0.7,0.8,0.5) )
file path needs to be adjusted according to your folder structure. it seems jsonlite automatically flattens the lists and replaces null values with NA
Closed by #11.