Although very handy and useful, I think most new R
developers do not even know that tables
exist. They are a little tricky to use, but they offer some nice functionality. These tables
become even more useful when we can visualize them as networks. This little bit of code is a rough first attempt at converting tables to network nodes and edges.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reading in 'dogs.csv' | |
# Created by Alex Bresler, available at: | |
# https://github.com/abresler/abresler.github.io/blob/master/blog/2015/february/exploring_agility_show/data/dogs.csv | |
dogs <- read.csv("dogs.csv", header = TRUE, stringsAsFactors = FALSE) | |
# Setting a numeric id | |
node_id <- 1:nrow(dogs) | |
# Getting unique values for the 'breed' column | |
unique_node_2 <- unique(dogs$breed) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the latest version of 'DiagrammeR' | |
install_github("rich-iannone/DiagrammeR") | |
# Create a 'nodes' data frame | |
nodes <- sample(1:100, 100, replace = FALSE) | |
style <- rep("filled", 100) | |
fillcolor <- c(rep("turquoise", 20), rep("pink", 20), | |
rep("ochre", 20), rep("gray40", 20), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#devtools::install_github("rstudio/leaflet", ref="feature/color-legend") | |
library(leaflet) | |
library(RColorBrewer) | |
set.seed(100) | |
pdf <- data.frame(Latitude = runif(100, -90,90), Longitude = runif(100, -180,180)) | |
#make a property with colors | |
pdf$Study <- rep(1:10,10) | |
#need to create a pal using colorbin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Title: Back to basics: High quality plots using base R graphics | |
### An interactive tutorial for the Davis R Users Group meeting on April 24, 2015 | |
### | |
### Date created: 20150418 | |
### Last updated: 20150423 | |
### | |
### Author: Michael Koontz | |
### Email: [email protected] | |
### Twitter: @michaeljkoontz | |
### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set a seed | |
set.seed(500) | |
library(MASS) | |
data <- Boston | |
# Check that no data is missing | |
apply(data,2,function(x) sum(is.na(x))) | |
# Train-test random splitting for linear model |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Installation | |
#install.packages("devtools") | |
devtools::install_github("rich-iannone/DiagrammeR") | |
library(DiagrammeR) | |
# Create a graph of border coordinates | |
country_graph <- country_graph() | |
# Read in a CSV with location and population data for cities all over the world |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(DiagrammeR) | |
library(magrittr) | |
library(visNetwork) | |
moments <- | |
'https://gist.githubusercontent.com/rich-iannone/9c4e50cd5d811b841349/raw/65bc97ddac2f9e52a4252fcf2060007fe1afeb7d/moment.csv' %>% | |
read_csv() | |
# Generate the court | |
court <- |
Built with blockbuilder.org
Nesting and summarizing data is a very common task for data analysis. I thought it would be nice to view parallel ways of nesting and summarizing with both
- R |
tidyr
anddplyr
- JavaScript |
d3.js
...v4 for fun
To avoid context switching, I'll take advantage of the R package V8
. If you are an R user, then these d3.js
gists might be helpful d3 nest examples and Mister Nester.
OlderNewer