library(magrittr)
library(tibble)
library(tidyr)
#>
#> Attaching package: 'tidyr'
#> The following object is masked from 'package:magrittr':
#>
#> extract
library(dplyr)
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
# Check this out; NSE functional assignment | |
# Works for functions that take a single `x` argument | |
# and linear pipe only downstream | |
myfun <- . %>% | |
sqrt() %>% | |
as.character() %>% | |
paste("is the coolest number ever!") | |
myfun(9) |
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
# Many RStudio engineers were using this font | |
# https://github.com/tonsky/FiraCode | |
a >= 10 | |
a != b | |
a <- 4 | |
a == 10 | |
a <= 10 |
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
# Set up custom debugging environment | |
.customCommands <- new.env() | |
assign("bug", structure("", class = "debugger_class"), envir = .customCommands) | |
assign("print.debugger_class", function(debugger) { | |
if ( !identical(as.character(getOption("error")), "rlang::entrace") ) { | |
options(error = quote(rlang::entrace()), | |
rlang__backtrace_on_error = "full") # or "collapse" | |
message( | |
crayon::green( | |
cli::symbol$tick, |
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
foo <- list(a = 1:5, b = letters, c = data.frame(set = 1:4)) | |
key <- c(b = "super", a = "awesome", c = "wicked") | |
nm <- . %>% purrr::map_chr(~ key[[.x]]) | |
foo %>% purrr::set_names(nm) |
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
# General use suggested .Rprofile for env setup | |
# Include additional functionality as required | |
# 2019-01-24 | |
# Stu Field, Bioinformatics, SomaLogic, Inc. | |
# --------------------------------------------------- # | |
# ------------------------- # | |
## session options | |
# ------------------------- # | |
options( |
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
#!/bin/sh | |
echo | |
echo "Thank you for contributing to the ..." | |
echo " ___ ___ _____ __ ___ _____ _______ ___ " | |
echo " (_-</ o \\/ \\ /o \\\\ |/ / -_) __(_-</ -_)" | |
echo "/___/\\___/__Y_Y__\\/_/\\_\\\\__/\\__/_/ /___/\\__/ " | |
# Read user input, assign stdin to keyboard |
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
reprex::reprex({ | |
library(magrittr) | |
library(SomaObjects) | |
library(tibble) | |
library(feather) | |
t_feather <- purrr::map_dbl(1:10, ~ { | |
t <- Sys.time() | |
write_feather(SurvData, "/tmp/surv.feather") | |
as.numeric(Sys.time() - t) | |
}) %>% mean() |
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
reprex::reprex({ | |
library(magrittr) | |
library(tibble) | |
suppressMessages(library(tidyr)) | |
suppressMessages(library(dplyr)) | |
# Option 1 | |
# Proper nesting of cyl using group_by | |
df1 <- mtcars %>% | |
group_by(cyl) %>% |
OlderNewer