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
| # generic place name maps in great britain (not northern ireland, my dataset didn't include it) | |
| # I used the place name data from https://www.ordnancesurvey.co.uk | |
| # it doesn't include latitude or longitude, rather "geometry_x", "geometry_y" values which correspond | |
| # to the british ordinance survey national grid | |
| # where 'geometry_x' is the number of metres east of the southwest corner of the grid | |
| # and 'geometry_y' is the number of metres north of the southwest corner of the grid | |
| # I am using the sgo library to convert BNG to WGS84 | |
| # (note: WGS84 is the standard, google maps location format) |
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
| <html> | |
| <head> | |
| <title>A Leaflet map!</title> | |
| <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css"/> | |
| <script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script> | |
| <style> | |
| #map{ height: 100% } | |
| </style> | |
| </head> | |
| <body> |
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
| # Using airquality dataset | |
| data <- airquality | |
| data[4:10,3] <- rep(NA,7) | |
| data[1:5,4] <- NA | |
| # Removing categorical variables | |
| data <- airquality[-c(5,6)] | |
| summary(data) | |
| #------------------------------------------------------------------------------- |
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: "Making Interactive Maps of Public Data in R" | |
| author: "Ryan Rosenberg" | |
| output: html_document | |
| --- | |
| <style> | |
| .leaflet { | |
| margin: auto; | |
| } | |
| </style> |
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(data.table) | |
| ?`[.data.table` | |
| DT <- data.table(x=rep(c("b","a","c"),each=3), y=c(1,3,6), v=1:9) | |
| X <- data.table(x=c("c","b"), v=8:7, foo=c(4,2)) | |
| colnames(DT) | |
| # [1] "x" "y" "v" |
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
| # restore_packages.R | |
| # | |
| # installs each package from the stored list of packages | |
| # source: http://hlplab.wordpress.com/2012/06/01/transferring-installed-packages-between-different-installations-of-r/ | |
| load("~/installed_packages.rda") | |
| for (count in 1:length(installedpackages)) { | |
| install.packages(installedpackages[count]) | |
| } |
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
| # run on old computer / r version | |
| setwd("C:/Temp/") # or any other existing temp directory | |
| setwd("/Users/Florian/Dropbox/temp") | |
| packages <- installed.packages()[,"Package"] | |
| save(packages, file="Rpackages") | |
| # run on new computer / r version | |
| setwd("C:/Temp/") # or any other existing temp directory | |
| load("Rpackages") |