This is an simple example of an R Markdown created GitHub Pages page.
Here are some examples of plots you can create and include in your page.
library(WDI)
library(googleVis)
co2 <- WDI(indicator = 'EN.ATM.CO2E.PC', start = 2010, end = 2010)
co2 <- co2[, c('iso2c','EN.ATM.CO2E.PC')]
# Clean
names(co2) <- c('iso2c', 'CO2 Emissions per Capita')
co2[, 2] <- round(log(co2[, 2]), digits = 2)
# Plot
co2_map <- gvisGeoChart(co2, locationvar = 'iso2c',
colorvar = 'CO2 Emissions per Capita',
options = list(
colors = "['#fff7bc', '#d95f0e']"
))
print(co2_map, tag = 'chart')
library(devtools)
library(ggplot2)
library(plotly)
source_url("http://bit.ly/OTWEGS")
# Create data with no missing values of infant mortality
InfantNoMiss <- subset(MortalityGDP,
!is.na(InfantMortality))
# Create High/Low Income Variable
InfantNoMiss$DumMort[InfantNoMiss$InfantMortality
>= 15] <- "high"
InfantNoMiss$DumMort[InfantNoMiss$InfantMortality
< 15] <- "low"
# Create ggplot2 object
mort_plot <- ggplot(data = MortalityGDP, aes(x = InfantMortality,
y = GDPperCapita)) + geom_point() +
stat_smooth(se = FALSE) +
ylab('GDP per Capita') + xlab('Infant Mortality') +
theme_bw(base_size = 9)
# Plot interactive
ggplotly(mort_plot)
plot_ly(MortalityGDP, x = InfantMortality, y = GDPperCapita,
mode = 'markers')
library(simGLM) # if not installed use devtools::github_install('christophergandrud/simGLM')
# Download data
URL <- 'http://www.ats.ucla.edu/stat/data/binary.csv'
Admission <- read.csv(URL)
Admission$rank <- as.factor(Admission$rank)
# Estimate model
m2 <- glm(admit ~ gre + gpa + rank, data = Admission, family = 'binomial')
# Create fitted values
fitted_admit <- expand.grid(gre = seq(220, 800, by = 10), gpa = c(1, 4),
rank4 = 1)
# Simulate and plot
sim_gpa <- sim_glm(obj = m2, newdata = fitted_admit, model = 'logit', x_coef = 'gre',
group_coef = 'gpa') + theme_bw(base_size = 9)
# Plot with plotly
ggplotly(sim_gpa)
library(dygraphs)
lungDeaths <- cbind(mdeaths, fdeaths)
dygraph(lungDeaths) %>% dyRangeSelector()
library(networkD3)
data(MisLinks); data(MisNodes)
forceNetwork(Links = MisLinks, Nodes = MisNodes,
Source = "source", Target = "target",
Value = "value", NodeID = "name",
Group = "group", opacity = 0.8)