This file contains 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
#include <iostream> | |
void passValue(int x) | |
{ | |
x += 2; | |
} | |
void passRef(int &x) | |
{ | |
x += 2; |
This file contains 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(dplyr, warn.conflicts = FALSE) | |
l <- letters[1:3] | |
n <- 1:3 | |
df <- tibble(x = c(rep(l, 2), "x")) | |
# thanks to Bret Beheim | |
df %>% mutate(y = n[match(x, l)]) | |
# thanks to Lisa DeBruine and Brenton Wiernik |
This file contains 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
# code for this tweet: | |
# https://twitter.com/patilindrajeets/status/1379114056590708736?s=20 | |
library(ggstatsplot) | |
library(gginnards) | |
df <- | |
data.frame( | |
"time-1" = c("Disease", "Disease", "No Disease", "Disease", "Disease"), | |
"time-2" = c("Disease", "Disease", "No Disease", "No Disease", "No Disease") |
This file contains 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
# setup | |
set.seed(123) | |
library(ggplot2) | |
library(ggrepel) | |
library(forcats) | |
# data | |
(df <- structure( | |
list( | |
cyl = structure( |
This file contains 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
# setup | |
set.seed(123) | |
library(tidyverse) | |
library(hrbrthemes) | |
library(ggplot2) | |
library(ggrepel) | |
# make the dataframe | |
df <- | |
tibble::tribble( |
This file contains 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(tidyverse) | |
iris %>% | |
tibble::as_tibble(.) %>% | |
dplyr::mutate(., row_mean = pmap_dbl(list(Sepal.Length, Sepal.Width), mean)) | |
#> # A tibble: 150 x 6 | |
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species row_mean | |
#> <dbl> <dbl> <dbl> <dbl> <fct> <dbl> | |
#> 1 5.1 3.5 1.4 0.2 setosa 5.1 |