If you want to know how many lines of code are in an Rmd file:
rmarkdown::render("file.Rmd", output_format = "md_document")
cat file.md | grep -c '^ \{4\}'
And then how many lines of code in .R files:
walk_source <- function( | |
file = NULL, | |
delay = 1.5, | |
clear_each_cmd = TRUE, | |
style = styler::tidyverse_style | |
) { | |
options("walk_source_cancel" = FALSE) | |
if (is.null(file)) { | |
txt <- rstudioapi::getSourceEditorContext()$contents | |
} else { |
#' Function to partition unequal sized groups into shards of similar size. | |
#' | |
#' Based on the greedy algorithm described in [The Wikipedia article on the | |
#' the partitioning problem](https://en.wikipedia.org/wiki/Partition_problem#The_greedy_algorithm) | |
#' | |
#' @param groups_vector An integer vector of group ids, such as a group ID | |
#' column in a data frame | |
#' @param n_shards The number of shards to split groups up into | |
#' @examples | |
#' n_groups <- 200 |
# Try-out of Hastie, Tibshirani, & Friedman (ESL, 2009) p.659 | |
# Generate high-dimensional dataset | |
beta <- -100:100/100 | |
X <- matrix(rnorm(100*201), 100) | |
y <- X%*%beta + rnorm(100, 0, sqrt(crossprod(beta))) | |
# Ridge estimates | |
bhat_ridge <- solve(crossprod(X) + diag(rep(.1, 201)), crossprod(X, y)) |
#!/usr/bin/env python3 | |
import csv | |
import time | |
import tweepy | |
import datetime | |
# Read http://docs.tweepy.org/en/v3.5.0/auth_tutorial.html to fill in the two lines below. | |
auth = tweepy.OAuthHandler('XXX', 'YYY') | |
auth.set_access_token('123', '456') |
<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; | |
}); |
#!/usr/bin/env bash | |
# Configuration | |
# The remote target branch name needs to be | |
# 1. DIFFERENT from the local development branch | |
# 2. Set as the default branch name on GitHub | |
remote_target_branch=master | |
generated_contents_dir=_site | |
get-working-branch() { |
strip_glm <- function(cm) { | |
cm$y = c() | |
cm$model = c() | |
cm$residuals = c() | |
cm$fitted.values = c() | |
cm$effects = c() | |
cm$qr$qr = c() | |
cm$linear.predictors = c() | |
cm$weights = c() |
If you want to know how many lines of code are in an Rmd file:
rmarkdown::render("file.Rmd", output_format = "md_document")
cat file.md | grep -c '^ \{4\}'
And then how many lines of code in .R files:
library(jsonlite) | |
## Download | |
pkgs <- fromJSON("http://crandb.r-pkg.org/-/events") | |
## Filter | |
na_pkgs <- unique(pkgs$name[ is.na(pkgs$date) ]) | |
events <- pkgs[ ! pkgs$name %in% na_pkgs, c("date", "name", "event")] |
# Download Kallisto and sratools (the latter to be able to download from SRA) | |
wget https://github.com/pachterlab/kallisto/releases/download/v0.42.3/kallisto_mac-v0.42.3.tar.gz | |
tar zvxf kallisto_mac-v0.42.3.tar.gz | |
wget http://ftp-trace.ncbi.nlm.nih.gov/sra/sdk/2.5.2/sratoolkit.2.5.2-mac64.tar.gz | |
tar zxvf sratoolkit.2.5.2-mac64.tar.gz | |
# Download and merge human cDNA and ncDNA files from Ensembl for the index. | |
wget ftp://ftp.ensembl.org/pub/current_fasta/homo_sapiens/cdna/Homo_sapiens.GRCh38.cdna.all.fa.gz | |
wget ftp://ftp.ensembl.org/pub/current_fasta/homo_sapiens/ncrna/Homo_sapiens.GRCh38.ncrna.fa.gz | |
cat Homo_sapiens.GRCh38.cdna.all.fa.gz Homo_sapiens.GRCh38.ncrna.fa.gz > Homo_sapiens.GRCh38.rna.fa.gz |