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(sp) | |
library(ggmap) | |
library(RColorBrewer) | |
## Get data from OpenPV. Open this URL: | |
## https://openpv.nrel.gov/search?&state=CA&minsize=100&maxsize=30600&pagenum=1&nppage=25 | |
## and export the results as a CSV file named "californiaOpenPV.csv" | |
caPV <- read.csv('californiaOpenPV.csv') | |
## Longitude and Latitude are the names of columns where the spatial information is stored. | |
## With the coordinates<- method caPV is now an SpatialPointsDataFrame |
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(movies, package='ggplot2') | |
library(lattice) | |
movies <- data.table(movies) | |
nBins <- 500 | |
## 2D Binning | |
movies[, c('ratBin', 'votesBin'):=list(floor(rating/nBins), floor(votes/nBins))] |
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) | |
library(lattice) | |
## Create a toy example | |
dt <- data.table(A=rnorm(1e7, mean=0, sd=1)) | |
## Bin the data using equal-width intervals | |
brks <- seq(-6, 6, length=10000) | |
## and := to avoid an additional copy | |
dt[,bin:=findInterval(A, brks)] | |
## Finally aggregate with mean by bin |
NewerOlder