Skip to content

Instantly share code, notes, and snippets.

View daroczig's full-sized avatar

Gergely Daróczi daroczig

View GitHub Profile
> library(pander)
> str(Pandoc.brew(text='Pi equals to <%=pi%>.\nAnd here are some random data:\n<%=runif(10)%>'))
Pi equals to _3.142_.
And here are some random data:
_0.9281_, _0.7048_, _0.5285_, _0.469_, _0.4796_, _0.844_, _0.2564_, _0.8511_, _0.5924_ and _0.8484_
List of 3
$ :List of 4
..$ type : chr "text"
..$ text :List of 2
.. ..$ raw : chr "Pi equals to <%=pi%>.\nAnd here are some random data:\n"
@daroczig
daroczig / README.md
Created February 23, 2014 22:03
Estimating the number of homeless people living in Hungary between 1999 and 2011

Placeholder for supplementary resources for the above BMS article.

@daroczig
daroczig / README.md
Created April 14, 2014 20:46
Demo statistical report template for "Creating statistical reports in the past, present and future"

A "rapport" template published in Gergely Daróczi (2014): "Creating statistical reports in the past, present and future". Romanian Statistical Review. (?)?: ?-?

> dim(m)
[1] 32400 32400
> sum(m) / prod(dim(m))
[1] 0.0007337982
> table(rowSums(m))
0 16 22 26 35 38 41 46
15549 96 30 29 28 27 26 16615
> table(colSums(m))
@daroczig
daroczig / commands_to_run
Last active August 29, 2015 14:07
evals demo
library(pander)
evals(readLines('demo.R'))
@daroczig
daroczig / Dockerfile
Created May 14, 2015 19:53
R with Java Docker container based on https://github.com/rocker-org/rocker
## Start with the official rocker image (lightweight Debian)
FROM rocker/r-base:latest
MAINTAINER Gergely Daroczi <gergely.daroczi@card.com>
## Install Java
RUN echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" \
| tee /etc/apt/sources.list.d/webupd8team-java.list \
&& echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" \
| tee -a /etc/apt/sources.list.d/webupd8team-java.list \
@daroczig
daroczig / meme.jpg
Last active August 29, 2015 14:23
Markdown preview via shiny, pandoc and pander
meme.jpg
@daroczig
daroczig / server.R
Created June 29, 2015 11:32
Markdown preview via shiny, pandoc and rmarkdown
library(shiny)
library(rmarkdown)
shinyServer(function(input, output) {
output$html = reactive({
t <- tempfile()
cat(input$markdown, file = t)
@daroczig
daroczig / impala.R
Last active February 2, 2017 17:10
Connect and query Imapala via SSH and Impala-shell from R
#' Connect and query Imapala via SSH and Impala-shell
#' @param query SQL query to run
#' @param host server hostname or IP
#' @param log enable or disable logging of debug/trace messages
#' @return data.table object
#' @export
query_impala <- function(query, host = 'localhost', log = require(futile.logger)) {
## measure time of query
timer <- proc.time()
@daroczig
daroczig / meetup-members.R
Last active December 19, 2017 15:25
Fetch the number of R User Group members around the world
library(XML)
html <- htmlParse(readLines('https://www.meetup.com/topics/r-project-for-statistical-computing/all/'))
names <- xpathSApply(html, '//li[@class="gridList-item"]/a/span', xmlValue)
attrs <- xpathSApply(html, '//li[@class="gridList-item"]/span[@class="text--secondary text--small chunk"]', xmlValue)
attrs <- gsub('\\n|\\t', '', attrs)
users <- as.numeric(gsub(',', '', sub('^([0-9,]*) .*', '\\1', attrs)))
geo <- sub('.* \\| ', '', attrs)
data.frame(name = names, location, members)