Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
"""Kernel K-means""" | |
# Author: Mathieu Blondel <mathieu@mblondel.org> | |
# License: BSD 3 clause | |
import numpy as np | |
from sklearn.base import BaseEstimator, ClusterMixin | |
from sklearn.metrics.pairwise import pairwise_kernels | |
from sklearn.utils import check_random_state |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
license: gpl-3.0 | |
redirect: https://observablehq.com/@d3/d3-color-schemes |
doInstall <- TRUE | |
toInstall <- c("alphahull") | |
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")} | |
lapply(toInstall, library, character.only = TRUE) | |
# Generate some sample data: | |
myData <- data.frame(x = rnorm(500), y = rnorm(500)) | |
# With a unit-circle hole in the center: | |
myData <- myData[sqrt(rowSums(myData^2)) > 1, ] | |
plot(myData) |
library(shiny) | |
library(datasets) | |
library(ggplot2) # load ggplot | |
# Define server logic required to plot various variables against mpg | |
shinyServer(function(input, output) { | |
# Compute the forumla text in a reactive function since it is | |
# shared by the output$caption and output$mpgPlot functions | |
formulaText <- reactive(function() { |
doInstall <- TRUE # Change to FALSE if you don't want packages installed. | |
toInstall <- c("ggplot2") | |
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")} | |
lapply(toInstall, library, character.only = TRUE) | |
# Generate some randomly-distributed data | |
nObs <- 5000 | |
myData <- data.frame(X = rnorm(nObs), Y = rnorm(nObs)) | |
nClusters <- 7 # Cluster it | |
kMeans <- kmeans(myData, centers = nClusters) |
require(inline) | |
require(RcppArmadillo) | |
## extract cosine similarity between columns | |
cosine <- function(x) { | |
y <- t(x) %*% x | |
res <- 1 - y / (sqrt(diag(y)) %*% t(sqrt(diag(y)))) | |
return(res) | |
} |
This post examines the features of [R Markdown](http://www.rstudio.org/docs/authoring/using_markdown) | |
using [knitr](http://yihui.name/knitr/) in Rstudio 0.96. | |
This combination of tools provides an exciting improvement in usability for | |
[reproducible analysis](http://stats.stackexchange.com/a/15006/183). | |
Specifically, this post | |
(1) discusses getting started with R Markdown and `knitr` in Rstudio 0.96; | |
(2) provides a basic example of producing console output and plots using R Markdown; | |
(3) highlights several code chunk options such as caching and controlling how input and output is displayed; | |
(4) demonstrates use of standard Markdown notation as well as the extended features of formulas and tables; and | |
(5) discusses the implications of R Markdown. |
# the code uses 'facebook' function from the previous gist (https://gist.github.com/1634662) or | |
# see the original http://romainfrancois.blog.free.fr/index.php?post/2012/01/15/Crawling-facebook-with-R | |
# scrape the list of friends | |
friends <- facebook( path="me/friends" , access_token=access_token) | |
# extract Facebook IDs | |
friends.id <- sapply(friends$data, function(x) x$id) | |
# extract names | |
friends.name <- sapply(friends$data, function(x) iconv(x$name,"UTF-8","ASCII//TRANSLIT")) | |
# short names to initials |
license: gpl-3.0 | |
redirect: https://observablehq.com/@d3/d3-horizon-chart |