Skip to content

Instantly share code, notes, and snippets.

View abnova's full-sized avatar

Aleksandr Blekh abnova

View GitHub Profile
@abnova
abnova / tsHSales.txt
Created February 27, 2015 04:07
Text dump of 'hsales' data set from 'fma' R package (restore by assigning the contents to an arbitrary R object) -- Re: discussion at http://stats.stackexchange.com/a/139518/31372
structure(c(55, 60, 68, 63, 65, 61, 54, 52, 46, 42, 37, 30, 37,
44, 55, 53, 58, 50, 48, 45, 41, 34, 30, 24, 29, 34, 44, 54, 57,
51, 51, 53, 46, 46, 46, 39, 41, 53, 55, 62, 55, 56, 57, 59, 58,
55, 49, 47, 57, 68, 84, 81, 78, 74, 64, 74, 71, 63, 55, 51, 57,
63, 75, 85, 80, 77, 68, 72, 68, 70, 53, 50, 53, 58, 73, 72, 68,
63, 64, 68, 60, 54, 41, 35, 43, 44, 44, 36, 44, 50, 55, 61, 50,
46, 39, 33, 37, 40, 49, 44, 45, 38, 36, 34, 28, 29, 27, 29, 28,
29, 36, 32, 36, 34, 31, 36, 39, 40, 39, 33, 44, 46, 57, 59, 64,
59, 51, 50, 48, 51, 45, 48, 52, 58, 63, 61, 59, 58, 52, 48, 53,
55, 42, 38, 48, 55, 67, 60, 65, 65, 63, 61, 54, 52, 51, 47, 55,
@abnova
abnova / nrowDir.R
Last active August 29, 2015 14:06
Print number of rows in each R data object file in a current directory
lapply(seq_along(a), function(i) {print(paste0(a[i], ": ", nrow(readRDS(a[i]))))})
@abnova
abnova / rUpdateFlex.R
Created September 16, 2014 05:46
Script for flexible updating R from both CRAN (primary) and R-Forge
# Answer by Sharpie to the following SO question:
# http://stackoverflow.com/q/3971815/2872891
# 1. Get the list of packages you have installed,
# use priority to exclude base and recommended packages.
# that may have been distributed with R.
pkgList <- installed.packages(priority='NA')[,'Package']
# 2. Find out which packages are on CRAN and R-Forge. Because
# of R-Forge build capacity is currently limiting the number of
@abnova
abnova / find_big_files.sh
Created September 15, 2014 04:36
Unix: Find files with size greater than 10MB and print them with size in bytes in a descending order (my version)
sudo find / -size +10M -printf "%k %p\n" 2>&1 | sort -k 1 -g -r | grep -v "No such file"
@abnova
abnova / word2tex.sh
Created August 19, 2014 03:43
A template for a shell script for converting an MS-Word document to a TeX document
# Reproducible process to convert a Microsoft Word document into a TEX document
#
# (Currently under development; partially based on information in the following discussion:
# http://tex.stackexchange.com/questions/46015/converting-ms-word-doc-to-latex-by-command-line)
#
# Step 1. Save Word file as ODT
#
# Step 2. Install or verify installation of Writer2LaTeX (TODO: automate)
# (http://writer2latex.sourceforge.net/)
#
@abnova
abnova / gist:70821f5bf1386b986fe1
Created August 18, 2014 09:24
Contents of the "demo-slides.log" file
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian) (format=pdflatex 2014.8.10) 18 AUG 2014 05:17
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**demo-slides
(./demo-slides.tex
LaTeX2e <2011/06/27>
Babel <3.9h> and hyphenation patterns for 2 languages loaded.
(/usr/share/texmf/tex/latex/beamer/base/beamer.cls
(/usr/share/texmf/tex/latex/beamer/base/beamerbasercs.sty
@abnova
abnova / latex.sh
Last active August 29, 2015 14:05
LaTeX-related
export TEXINPUTS=".:path/to/image:other/path:"
#export TEXINPUTS=~/diss-floss/figures//:~/diss-floss/present/images//:${TEXINPUTS}
@abnova
abnova / checkDataRDS.R
Last active August 29, 2015 14:05
Quick check of data stored in current directory's RDS files
a <- dir()
lapply(seq_along(a), function(i) head(readRDS(a[i]), 20))
lapply(seq_along(a), function(i) tail(readRDS(a[i]), 20))
@abnova
abnova / rds2rda.R
Last active August 29, 2015 14:05
Utility that converts indicator-named RDS files into a single RDA file with correspondingly named objects.
rm(list=ls(all=TRUE)) # Clear R environment from previous sessions
rds2rda <- function(dataDir = ".", archiveFile = "mergeTestData.rda") {
workDir <- getwd() # save working directory
setwd(dataDir) # set new working directory
objects <- list()
for (file in dir(pattern='\\.rds$')) {
@abnova
abnova / loadRDataDir
Created July 8, 2014 07:27
An attempt to load data from all RData files in a specified directory into a single data table
library(data.table)
fileList <- list.files("../cache/FLOSSmole", pattern="\\.RData$", full.names=TRUE)
dataset <- rbindlist(lapply(fileList, FUN=function(file) {as.data.table(load(file))}))