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
| # 1. functions for yearmon transformer ================ | |
| # Convert from numeric to yearmon | |
| to_yearmon <- function(x) as.yearmon(x) | |
| # Inverse: convert from yearmon to numeric | |
| from_yearmon <- function(x) { | |
| if (!inherits(x, "yearmon")) { | |
| stop("Invalid input: date_yearmon works with objects of class yearmon only", | |
| call. = FALSE) |
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(inline) | |
| inc <- ' | |
| /* This is taken from envir.c in the R 2.15.1 source | |
| https://github.com/SurajGupta/r-source/blob/master/src/main/envir.c | |
| */ | |
| #define FRAME_LOCK_MASK (1<<14) | |
| #define FRAME_IS_LOCKED(e) (ENVFLAGS(e) & FRAME_LOCK_MASK) | |
| #define UNLOCK_FRAME(e) SET_ENVFLAGS(e, ENVFLAGS(e) & (~ FRAME_LOCK_MASK)) | |
| ' |
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
| Examples for controls | |
| ======================================================== | |
| ```{r tidy=FALSE, fig.width=4, fig.height=3 } | |
| library(ggplot2) | |
| # Base plot | |
| p <- ggplot(ToothGrowth, aes(x=factor(dose), y=len, fill=supp)) + | |
| scale_fill_manual(values=c("#E69F00", "#377EB8")) |
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
| tell application "RStudio" | |
| activate | |
| tell application "System Events" | |
| tell application process "RStudio" | |
| keystroke "t0 <- Sys.time()" | |
| key code 36 using command down | |
| key code 36 | |
| keystroke "asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf" | |
| key code 36 | |
| keystroke "t1 <- Sys.time(); t1-t0" |
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(gcookbook) | |
| library(ggplot2) | |
| # Take a slice where z is equal to the minimum value of z | |
| islice <- subset(isabel, z == min(z)) | |
| # Just the hurricane data | |
| ggplot(islice, aes(x=x, y=y, fill=speed)) + geom_raster(alpha=.5) + | |
| scale_fill_continuous(na.value=NA) |
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(shiny) | |
| library(datasets) | |
| library(ggplot2) | |
| tg <- ToothGrowth | |
| tg$dose <- factor(tg$dose) | |
| # Define server logic | |
| shinyServer(function(input, output) { |
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
| State | Abbrv | Longitude | Latitude | |
|---|---|---|---|---|
| california | CA | 3 | 12 | |
| washington | WA | 3 | 18.5 | |
| oregon | OR | 4 | 17 | |
| nevada | NV | 5 | 15.5 | |
| idaho | ID | 7 | 16.5 | |
| utah | UT | 7 | 14.5 | |
| arizona | AZ | 8 | 9 | |
| montana | MT | 9 | 17.5 | |
| wyoming | WY | 9 | 15.5 |
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(shiny) | |
| shinyServer(function(input, output) { | |
| output$main_plot <- reactivePlot(function() { | |
| hist(faithful$waiting, | |
| breaks = as.numeric(input$n_breaks), | |
| xlab = "Time to next eruption (minutes)", | |
| main = "Waiting times for Old Faithful geyser") |
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
| shinyServer(function(input, output) { | |
| output$main_plot <- renderPlot(width = 400, height = 300, { | |
| hist(faithful$eruptions, | |
| probability = TRUE, | |
| breaks = as.numeric(input$n_breaks), | |
| xlab = "Duration (minutes)", | |
| main = "Geyser eruption duration") |
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(shiny) | |
| shinyServer(function(input, output) { | |
| output$main_plot <- reactivePlot(function() { | |
| plot(x = faithful$eruptions, y = faithful$waiting, | |
| xlab = "Eruption duration (minutes)", | |
| ylab = "Waiting to next eruption (minutes)", | |
| main = "Eruptions of Old Faithful geyser") |