Skip to content

Instantly share code, notes, and snippets.

View romainfrancois's full-sized avatar
🎉
tada⬢science ⬡⬡ ex(Posit/RStudio, ThinkR, Mango Solutions)

Romain François romainfrancois

🎉
tada⬢science ⬡⬡ ex(Posit/RStudio, ThinkR, Mango Solutions)
View GitHub Profile
library(css)
library(glue)
library(rvest)
library(stringr)
library(dplyr)
library(purrr)
directory <- "https://github.com/rstudio/rstudio/blob/master/src/gwt/src/org/rstudio/studio/client/workbench/views/source/editors/text/themes"
raw_directory <- "https://raw.githubusercontent.com/rstudio/rstudio/master/src/gwt/src/org/rstudio/studio/client/workbench/views/source/editors/text/themes"
rstudio_theme_names <- read_html(directory) %>%
library(rlang)
library(dplyr)
library(purrr)
replace_when <- function(data, target, ...){
target <- ensym(target)
mutate( data, !!target := case_when( !!!quos(...), TRUE ~ !!target ) )
}
d <- data.frame(x = 1:10, y = 1:10)
library(prenoms)
library(babynames)
library(ggplot2)
library(dplyr)
nnames <- function(data, origin){
data %>%
group_by(sex, year) %>%
summarise(n = length(unique(name))) %>%
mutate( origin = origin ) %>%
library(rlang)
library(dplyr)
library(purrr)
mutate_when <- function(data, condition, ...){
condition <- enquo(condition)
dots <- exprs(...)
---
title: "Summarise and mutate multiple columns"
output: html_document
---
```{r, include = FALSE}
library(dplyr)
knitr::opts_hooks$set(
asciicast = rsciinema::asciicast_hook
)
@romainfrancois
romainfrancois / install-mini.R
Created August 29, 2017 13:41 — forked from VincentGuyader/install-mini.R
configuration poste R
percent <- function(x, digits = 2, format = "f", ...) {
paste0(formatC(100 * x, format = format, digits = digits, ...), "%")
}
mon_print <- function(synth){
N <- nrow(synth)
if( is.null(N)){
N<-1
synth <-
matrix(synth,nrow=1)
@romainfrancois
romainfrancois / hack.R
Created August 17, 2017 10:10
emoji completion hack
.original.rs.getCompletionsFile <- .rs.getCompletionsFile
assign( ".rs.getCompletionsFile", function (token, path = getwd(), quote = FALSE, directoriesOnly = FALSE) {
if( grepl( ".*[:]", token ) ){
tok <- sub( ".*[:]", "", token)
start <- sub( "[:].*", "", token)
.rs.makeCompletions(
token = token , results = paste0( start, emo::ji_completion(tok) ) ,
excludeOtherCompletions = TRUE, type= .rs.acCompletionTypes$STRING,
quote = FALSE
library(emo)
library(stringr)
library(purrr)
emoji_name <- emo:::emoji_name
emoji_keyword <- emo:::emoji_keyword
maybe_emoji <- function( keyword ){
if (keyword %in% names(emoji_name)) {
library(tidyverse)
library(lubridate)
library(emoGG)
lexie <- tribble( ~date, ~weight,
"2017-07-12", 3.460,
"2017-07-13", 3.200,
"2017-07-14", 3.100,
"2017-07-15", 3.200,
"2017-07-16", 3.250,
library(rvest)
library(purrr)
library(tibble)
library(dplyr)
library(stringr)
attendees <- function(page) {
extract <- function(class) html_node( persons, class ) %>% html_text() %>% str_trim()
url <- paste0( 'https://user2017.sched.com/directory/attendees/', page )