Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# To rename files in bulk
# e.g., renaming `fasta` to `fa` | ABC.fasta XYZ.fasta to ABC.fa XYZ.fa
# ref: https://ryanstutorials.net/linuxtutorial/bonus.php#xargs
basename -s .fasta -a *.fasta | xargs -n1 -i mv {}.fasta {}.fa
@jananiravi
jananiravi / source_files_within_folder.R
Last active December 2, 2019 21:30
To source all R scripts within a single folder with tidyverse>purrr>map!
# If you want to use `tidyverse` to do this, you could use the `map` function to simplify!
my_path <- c("/path/to/files/") # set your path
source_files <- list.files(my_path, "*.R") # locate all .R files
map(paste0(my_path, source_files), source) # source all your R scripts!
# 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)"
# 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"),
@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
@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

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

version

               _                           
platform       x86_64-apple-darwin15.6.0   
arch           x86_64                      
os             darwin15.6.0                
system         x86_64, darwin15.6.0        
status                                     
major          3                           
@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)
@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))