Skip to content

Instantly share code, notes, and snippets.

View Thell's full-sized avatar

Thell 'Bo' Fowler Thell

  • Pyrapat Inc.
  • Arkansas, USA
View GitHub Profile
@Thell
Thell / sample.Rmd
Created October 24, 2012 22:57
SO-Answer-download-revise-upload-github-gists-with-r
This is a simple public sample.
---
It really should do more.
@Thell
Thell / Exmple.Rmd
Created June 20, 2013 23:59
R markdown to illustrate creation of in-document referencing for chunks, sections, pages, and such.
```{r setup, echo=FALSE, results='hide'}
chunkref <- local({
function(chunklabel) {
sprintf('[%s](#%s)', chunklabel, chunklabel )
}
})
secref <- local({
function(seclabel) {
sprintf('[%s](#%s)', seclabel, seclabel )
@Thell
Thell / gist:8324791
Created January 8, 2014 21:14
Possible Wrapper to skip the last n lines of R read.csv
myread.csv <- function( file, header=TRUE, sep=",", quote="\"", dec=".", fill=TRUE, comment.char="", skip.footer=0, ... ) {
file <- readLines(file)
if( skip.footer > 0 ) file <- file[-(skip.footer)]
read.csv( file, header, sep, quote, dec, fill, comment.char, ... )
}
// [[Rcpp::plugins("cpp11")]]
#include <ostream>
#include <iterator>
#include <RcppCommon.h>
class BadIter;
RCPP_EXPOSED_CLASS(BadIter)
#include <Rcpp.h>
@Thell
Thell / RCPP_EXPOSED_CLASS
Created February 27, 2014 01:20
Example of creation time for pre/post construction populated RCPP_EXPOSED_CLASS
// [[Rcpp::plugins("cpp11")]]
#include <RcppCommon.h>
class preVector;
RCPP_EXPOSED_CLASS(preVector)
class postVector;
RCPP_EXPOSED_CLASS(postVector)
@Thell
Thell / SO11533438
Created February 28, 2014 05:03
SO rmd
_Why_ it is so slow? A little research located a mail group posting from a year ago this month where @hadley, the package author, [states][2]
> This is a drawback of the way that ddply always works with data
frames. It will be a bit faster if you use summarise instead of
data.frame (because data.frame is very slow), but I'm still thinking
about how to overcome this fundamental limitation of the ddply
approach.
---
/***
*
* Scenario:
*
* You desire to use RCPP_EXPOSE_CLASS on a class and it needs to store
* a pointer to somewhere in a constructor initialized container either
* using the default initializer list or from within the constructor.
*
* Problem:
*
clang++ -I/usr/share/R/include -DNDEBUG -I../inst/include/ -I"/home/thell/R/x86_64-pc-linux-gnu-library/3.0/Rcpp/include" -fpic -Wall -O3 -c RcppExports.cpp -o RcppExports.o
14
** libs
15
clang++ -I/usr/share/R/include -DNDEBUG -I../inst/include/ -I"/home/thell/R/x86_64-pc-linux-gnu-library/3.0/Rcpp/include" -fpic -Wall -O3 -c RcppMultiPrecision.cpp -o RcppMultiPrecision.o
16
clang++ -shared -o RcppMultiPrecision.so RcppExports.o RcppMultiPrecision.o -lmpfr -lgmp -L/usr/lib/R/lib -lR
---
title: "SO22524822"
author: "Thell"
date: "03/21/2014"
output: html_document
---
```{r setup}
# A killPrefix hook.
default_output_hook <- knitr::knit_hooks$get("output")
@Thell
Thell / PandocMathTest.Rmd
Created April 9, 2014 23:57
Pandoc Mathjax Test Doc
---
title: "Pandoc MathTest"
author: "Thell"
date: "04/09/2014"
output:
html_document: default
pdf_document:
pandoc_args: --tex-escape-outer-math
---