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(sf) | |
library(dplyr) | |
library(albersusa) | |
library(crosstalk) | |
library(plotly) | |
usa <- usa_sf("laea") | |
# st_centroid gets the center POINT of polygons | |
uscenter <- usa %>% |
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(tidyverse) | |
library(plotly) | |
# I'm being lazy, please don't do this | |
# setwd("~/Downloads/Version 2_0_1/") | |
d <- read_csv('GEOSTAT_grid_POP_1K_2011_V2_0_1.csv') %>% | |
rbind(read_csv('JRC-GHSL_AIT-grid-POP_1K_2011.csv') %>% | |
mutate(TOT_P_CON_DT = '')) %>% | |
mutate( |
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(crosstalk) | |
library(htmltools) | |
m <- SharedData$new(mtcars) | |
set_values <- function(w, sharedData, values) { | |
script <- sprintf( | |
"HTMLWidgets.addPostRenderHandler(function() { return crosstalk.group('%s').var('%s').set(%s); })", | |
sharedData$groupName(), "filter", jsonlite::toJSON(values) | |
) |
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(plotly) | |
library(tidyr) | |
library(crosstalk) | |
m <- gather(mtcars, variable, value, -vs) | |
msd <- SharedData$new(m, ~variable) | |
gg <- ggplot(msd, aes(factor(vs), value)) + | |
geom_jitter(alpha = 0.3) | |
bscols(widths = c(11, 6, 6), |
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("ropensci/plotly") | |
library(plotly) | |
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf")) | |
# shared data will make the polygons "query-able" | |
ncsd <- crosstalk::SharedData$new(nc) | |
p <- ggplot(ncsd) + | |
geom_sf(aes(fill = AREA, text = paste0(NAME, "\n", "FIPS: ", FIPS))) + |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# setwd("~/Downloads") | |
readKMZ <- function(f = NULL) { | |
zip <- paste0(f, ".zip") | |
file.rename(f, zip) | |
unzip(zip) | |
geojsonio::geojson_read("doc.kml", what = "sp") | |
} | |
pts <- readKMZ("MWAHIST12282016.kmz") |
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
"country" "area" | |
"Russia" 17098246 | |
"Canada" 9984670 | |
"China" 9572900 | |
"United States" 9525067 | |
"Brazil" 8515767 | |
"Australia" 7692024 | |
"India" 3287263 | |
"Argentina" 2780400 | |
"Kazakhstan" 2724900 |
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(trelliscopecore) | |
library(dplyr) | |
library(plotly) | |
# cognostics data frame | |
iris_cog_df <- iris %>% | |
group_by(Species) %>% | |
summarise( | |
mean_sl = cog(mean(Sepal.Length), desc = "mean sepal length"), | |
mean_sw = cog(mean(Sepal.Width), desc = "mean sepal length"), |
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(plotly) | |
library(shiny) | |
# compute a correlation matrix | |
correlation <- round(cor(mtcars), 3) | |
nms <- names(mtcars) | |
ui <- fluidPage( | |
mainPanel( | |
plotlyOutput("heat"), |