A translation of the code in this blog post.
This file contains 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
# enable CORS policy | |
# https://gist.github.com/maxparm/3105526 | |
<IfModule mod_rewrite.c> | |
Header add Access-Control-Allow-Origin "*" | |
Header add Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT" | |
Header add Access-Control-Allow-Headers: "Content-Type" | |
RewriteEngine on | |
RewriteBase / | |
</IfModule> |
This file contains 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
name keywords | |
Felicitas Development, Corruption, Housing, Transportation, Religion | |
Lucile Inequality, Migration, Race and Gender, Community/Neighborhood | |
Corentin Inequality, Religion, Migration, Poverty, Gender | |
Charlotte Energy, Environment, Smart Cities, Conflict, Gender | |
Alice Environment, Gender, Migration, Urban Studies | |
Miranda Politics, Gender, Human Rights | |
Margaux Inequality, Urban Studies, Migration, Human Rights | |
Marina Critical Theory, Social Inequality, Race and Gender | |
Cosima Race and Gender and Sexuality, Spatial Inequality, Migration |
This file contains 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
#' Read Points out of a KML file. | |
#' | |
#' @param x A KML file exported from Google Maps. | |
#' @param layer The name of the layer to extract from: defaults to \code{"d1"}. | |
#' @param verbose Whether to report invalid coordinates and/or altitudes below | |
#' sea level; defaults to \code{TRUE}. See \link{kml_coordinate}. | |
#' @return A \link[tibble:tibble]{tibble} containing the \code{name}, | |
#' \code{description}, \code{styleUrl} and Point coordinates (\code{longitude}, | |
#' \code{latitude} and \code{altitude}) of each Placemark element contained in | |
#' the KML file. Placemark elements with no Point coordinates, such as Polygon |
This file contains 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
R to python useful data wrangling snippets | |
The dplyr package in R makes data wrangling significantly easier. | |
The beauty of dplyr is that, by design, the options available are limited. | |
Specifically, a set of key verbs form the core of the package. | |
Using these verbs you can solve a wide range of data problems effectively in a shorter timeframe. | |
Whilse transitioning to Python I have greatly missed the ease with which I can think through and solve problems using dplyr in R. | |
The purpose of this document is to demonstrate how to execute the key dplyr verbs when manipulating data using Python (with the pandas package). | |
dplyr is organised around six key verbs |
This file contains 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(dplyr) | |
library(readr) | |
library(rvest) | |
h = html("https://meta.wikimedia.org/wiki/Freedom_of_Panorama_in_Europe_in_2015/Contact_your_MEP") | |
l = html_nodes(h, xpath = "//a[contains(@href, 'Contact_your_MEP/')]") %>% | |
html_attr("href") %>% | |
unique |
This file contains 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
name keywords | |
Felicitas Development, Corruption, Housing, Transportation, Religion | |
Lucile Inequality, Migration, Race and Gender, Community/Neighborhood | |
Corentin Inequality, Religion, Migration, Poverty, Gender | |
Charlotte Energy, Environment, Smart Cities, Conflict, Gender | |
Alice Environment, Gender, Migration, Urban Studies | |
Miranda Politics, Gender, Human Rights | |
Margaux Inequality, Urban Studies, Migration, Human Rights | |
Marina Critical Theory, Social Inequality, Race and Gender | |
Cosima Race and Gender and Sexuality, Spatial Inequality, Migration |
This file contains 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 a PubMed search index | |
#' @param query a PubMed search string | |
#' @return the XML declaration of the search | |
#' @example | |
#' # Which articles discuss the WHO FCTC? | |
#' pubmed_ask("FCTC OR 'Framework Convention on Tobacco Control'") | |
pubmed_ask <- function(query) { | |
# change spaces to + and single-quotes to URL-friendly %22 in query | |
query = gsub("'", "%22", gsub(" ", "+", query)) |
This file contains 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
# ============================================================================== | |
# SESSION_INFO | |
# | |
# A script to deal with package dependencies that will | |
# | |
# - detach all packages except base ones | |
# - install its own package dependencies | |
# - look for session_info.txt and parse it for packages | |
# - ensure the packages are installed and up to date | |
# |
This file contains 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
# removes characters from multiple data frame columns | |
# example removes * , % characters | |
dw <- data.frame(gsub("\\*|,|%", "", as.matrix(dw)), stringsAsFactors = FALSE) |
NewerOlder