Skip to content

Instantly share code, notes, and snippets.

@jananiravi
jananiravi / css-customization-radix-rmarkdown.rmd
Created November 7, 2018 19:45
css customization for radix rmarkdown template
<style type="text/css">
body{ /* Normal */
font-size: 12px;
font-family: "Helvetica Neue", Helvetica, sans;
}
td { /* Table */
font-size: 8px;
font-family: "Helvetica Neue", Helvetica, sans;
}
h1.title {
@jananiravi
jananiravi / knitr-setup-chunk.rmd
Created November 7, 2018 19:57
knitr setup chunk for radix rmarkdown file (little redundant with the various width options; looking for suggestions)
```{r setup}
knitr::opts_chunk$set(
echo=TRUE, eval=TRUE,
warning=TRUE,
message=TRUE,
tidy=TRUE,
R.options=list(width=80),
tidy.opts=list(width.cutoff=80), # For code
width = 80,
# comment="##",
@jananiravi
jananiravi / find_local_tweeps.R
Last active February 19, 2019 23:16 — forked from stephlocke/find_local_tweeps.R
A visit to Michigan | Finding 'persons of interest' | Twitter
# Orig tweeps author: stephlocke
# Adapted to find data scientists in the Michigan, East Lansing area!
library(rtweet) #rtweet API creds should already be set up
library(stringi)
library(tidyverse)
friends = get_friends(user="gdequeiroz ") #stephlocke #JennyBryan #hadleywickham
followers = get_followers("gdequeiroz") #janani137
tweeps_id = distinct(bind_rows(friends, followers))
@jananiravi
jananiravi / r_warnings_clang_pkg_installation.md
Last active May 7, 2019 15:12
Package installation: https://github.com/thomasp85/FindMyFriends | R warnings generated when trying to install the package; clang/gcc/Rcpp/FindMyFriends issue?

> devtools::install_github('thomasp85/FindMyFriends')


Downloading GitHub repo thomasp85/FindMyFriends@master
Skipping 6 packages ahead of CRAN: BiocGenerics, Biostrings, IRanges, S4Vectors, XVector, zlibbioc
Installing 11 packages: apcluster, Biobase, BiocParallel, e1071, filehash, ggdendro, igraph, kebabs, kernlab, LiblineaR, snow
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6/apcluster_1.4.7.tgz'
Content type 'application/x-gzip' length 1949324 bytes (1.9 MB)

version

               _                           
platform       x86_64-apple-darwin15.6.0   
arch           x86_64                      
os             darwin15.6.0                
system         x86_64, darwin15.6.0        
status                                     
major          3                           

Makevars

# C
CC=clang
CFLAGS=-g -O2 -Wall -pedantic -mtune=native

# C++
CXX=clang++
CXXFLAGS=-g -O2 -Wall -pedantic -mtune=native
# -Wno-unused-local-typedef
@jananiravi
jananiravi / backstitch.R
Created August 14, 2019 16:41 — forked from gadenbuie/backstitch.R
Convert Rmd document (knitr::knit) to an R script (knitr::spin) #RMarkdown #knitr #knit #spin
warning("You probably don't want to use this `backstitch()` function.",
"\n It's hacky and there's a much better option in knitr called `purl()`.",
"\n More info at: `?knitr::purl`")
#' Backstitch an Rmd file to an R script
#'
#' Takes an Rmd file -- that would be converted with knitr::knit() -- and
#' "backstitches" it into an R script suitable for knitr::purl(). The output
#' file is the just the backstitched R script when `output_type = 'script'`, or
#' just the code chunks when `output_type = 'code'` (note that all inline code
@jananiravi
jananiravi / rmd2rscript.R
Created August 14, 2019 16:44
rmd2rscript: a function to convert R Markdown to an R script which can be sourced script for converting .Rmd files to .R scripts. (~ Kevin Keenan)
#' ## rmd2rscript: a function to convert R Markdown to an R script which can be sourced
#' ## script for converting .Rmd files to .R scripts.
#' ## Author: Kevin Keenan 2014
#' ## http://rstudio-pubs-static.s3.amazonaws.com/12734_0a38887f19a34d92b7311a2c9cb15022.html
#' ## Slightly modified by: Janani Ravi 2019
#'
#' This function will read a standard R markdown source file and convert it to
#' an R script to allow the code to be run using the "source" function.
#'
#' The function is quite simplisting in that it reads a .Rmd file and adds
# knitr::purl(input_file, output_file, documentation = 2)
infile <- "your_filename.Rmd"
inpath <- "docs/"; outpath <- "scripts/"
name <- strsplit(infile, split = "\\.")[[1]][1]
knitr::purl(paste0(inpath, infile),
paste0(outpath, name,
"_rmd2r_", format(Sys.time(), "%Y%m%d"),
# To install homebrew on macOS: Mojave, (High)Sierra, El Capitan, Yosemite
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"