library(magrittr)
library(dplyr)
library(stringr)
df <- mtcars; df$car <- rownames(df)
df %>%
mutate(make = str_extract(car, "^[A-Za-z]+\\b")) %>%
group_by(make) %>%
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
| your_handle <- "bearloga" | |
| # Note: must be logged in to twitter to view your own or anyone's list of followers | |
| library(magrittr) # install.packages('magrittr') | |
| library(rvest) # install.packages('rvest') | |
| library(RSelenium) # install.packages('RSelenium') | |
| # Scrolling solution by NicE (http://stackoverflow.com/a/29965233/1091835): | |
| checkForServer() | |
| startServer() |
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
| ## Script for scraping Wikipedia for data to use with the geom_flag() prototype | |
| ## CONTACT: Mikhail Popov (@bearloga // mikhail[at]mpopov[dot]com) | |
| ## URL: https://gist.github.com/bearloga/519a701a6a9bc7c3ba9f | |
| # install.packages("import") | |
| library(rvest) # install.packages("rvest") | |
| library(magrittr) | |
| import::from(dplyr, mutate, select, keep_where = filter, left_join, distinct) |
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
| suppressMessages({ | |
| # Preamble ======================================== | |
| # ======== Web Scraping =========================== | |
| library(rvest) # install.packages('rvest') | |
| library(magrittr) | |
| # ======== I/O ==================================== | |
| library(httr) # install.packages('httr') | |
| }) | |
| html <- read_html("https://wikipedia.org") |
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: "dyEvent Example" | |
| output: | |
| html_document: | |
| css: style.css | |
| --- | |
| ```{r setup, echo = FALSE, warning = FALSE, message = FALSE} | |
| library(xts) | |
| library(dygraphs) |
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
| <script language="JavaScript"> | |
| $(function() { | |
| /* Lets the user click on the images to view them in full resolution. */ | |
| $("div.figure img").wrap(function() { | |
| var link = $('<a/>'); | |
| link.attr('href', $(this).attr('src')); | |
| link.attr('title', $(this).attr('alt')); | |
| link.attr('target', '_blank'); | |
| return link; | |
| }); |
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
| # WMF only: | |
| if (file.exists("/etc/wikimedia-cluster")) { | |
| message('Detected that this script is being run on a WMF machine ("', Sys.info()["nodename"], '"). Setting proxies...') | |
| Sys.setenv("http_proxy" = "http://webproxy.eqiad.wmnet:8080") | |
| Sys.setenv("https_proxy" = "http://webproxy.eqiad.wmnet:8080") | |
| } | |
| # General use: | |
| message("Checking for a personal library...") | |
| if (!dir.exists(Sys.getenv("R_LIBS_USER"))) { |
I hereby claim:
- I am bearloga on github.
- I am mikhailpopov (https://keybase.io/mikhailpopov) on keybase.
- I have a public key ASCf0zmMPu2vZKS1L64MOIaEEZ2n4ZsLRhW64H1k0sO5TQo
To claim this, I am signing this object:
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
| header <- headerPanel("Hello Shiny!") | |
| header[[2]]$attribs$id = "header" | |
| ui <- fluidPage( | |
| tags$head( | |
| tags$link(rel = "stylesheet", type = "text/css", href = "custom.css") | |
| ), | |
| header, | |
| sidebarLayout( | |
| sidebarPanel(sliderInput("obs", "Number of observations:", min = 0, max = 1000, value = 500)), |