Skip to content

Instantly share code, notes, and snippets.

View ernestguevarra's full-sized avatar

Ernest Guevarra ernestguevarra

View GitHub Profile
@ernestguevarra
ernestguevarra / app.R
Created September 29, 2017 04:55 — forked from jcheng5/app.R
Using OAuth2 with Shiny
library(shiny)
# WARNING: This sketch does not make proper use of the "state" parameter.
# Doing so usually involves using cookies, which can be done with the
# Rook package but I have not done that here. If you choose to use this
# approach in production, please check the state parameter properly!
APP_URL <- if (interactive()) {
# This might be useful for local development. If not, just hardcode APP_URL
# to the deployed URL that you'll provide a few lines below.
@ernestguevarra
ernestguevarra / simLQAS.r
Created September 30, 2017 05:34
Test for LQAS classifier performance
#
# Close graphic devices and clear the workspace
#
graphics.off()
rm(list = ls())
gc()
#
# Simulation parameters
#
@ernestguevarra
ernestguevarra / wgs.r
Created September 30, 2017 07:41
Function to calculate z-scores for WHZ, HAZ, WAZ using the WHO Growth # Reference (2006) using data and methods from ISBN 92 4 154693 X.
################################################################################
#
# Function to calculate z-scores for WHZ, HAZ, WAZ using the WHO Growth
# Reference (2006) using data and methods from ISBN ISBN 92 4 154693 X.
#
################################################################################
#
# Parameters are :
#
# sexObserved : Sex
@ernestguevarra
ernestguevarra / .travis.yml
Created January 16, 2018 12:55
Travis settings for Shiny testing
dist: trusty # Use Ubuntu 14.04 image (instead of 12.04)
language: r
sudo: false
r: 3.4.1
# Install packrat if needed and have it restore packages.
install:
- R -e 'if (system.file(package="packrat") == "") install.packages("packrat")'
- R -e "packrat::packify(); packrat::restore()"
@ernestguevarra
ernestguevarra / zscore.apc
Created July 20, 2018 08:07
Calculating z-score flags using WHO Growth Standards flagging criteria
// Declare variables
numeric aNumber;
// Create logic variables for each of the HAZ flags
numeric hazLowerBoys;
hazLowerBoys = 0.000000379386 * cage ^ 5 - 0.000069515524 * cage ^ 4
+ 0.004909805 * cage ^ 3 - 0.168908042 * cage ^ 2
+ 3.266127182 * cage + 39.95107423
numeric hazUpperBoys;
@ernestguevarra
ernestguevarra / mathJaxExample.md
Created August 20, 2018 05:52
Example of MathJax syntax
Stepped wedge study design
We used the sample size calculations for a stepped wedge design proposed by Woertman et al1. Their calculations use the unadjusted sample size ($ n_{unadjusted} $) required for an individual randomised controlled trial for comparing two proportions and then adjusts this calculation based on the cluster design effect ($ DEFF $) to be expected in a stepped wedge design. Their equation for estimating the design effect of a stepped wedge study is as follows:  

$$ DEFF_{\text {stepped wedge}} = \frac {1 + p(ktn + bn - 1)}{1 + p \left(\frac {1}{2}ktn + bn - 1 \right )} \times \frac {3(1-p)}{2t \left (k-\frac{1}{k} \right )} $$

where

$ k = \text {number of steps} $ $ b = \text {number of baseline measurements} $

@ernestguevarra
ernestguevarra / tableExample.html
Created August 20, 2018 05:53
Example of tables in HTML
<a id="FIG1"></a><strong>Figure 1:</strong> Schematic diagram of the proposed stepped wedge cluster-randomised controlled trial
<style>
th, tr, td {
text-align:center;
font-family:Helvetica;
font-size:10px;
border:1px solid black;
}
</style>
library(dplyr)
library(sp)
library(rgdal)
library(tibble)
find_UTM_zone <- function(longitude, latitude) {
# Special zones for Svalbard and Norway
if (latitude >= 72.0 && latitude < 84.0 )
if (longitude >= 0.0 && longitude < 9.0)
@ernestguevarra
ernestguevarra / keybase.md
Created April 22, 2019 10:01
Keybase identity

Keybase proof

I hereby claim:

  • I am ernestguevarra on github.
  • I am ernestguevarra (https://keybase.io/ernestguevarra) on keybase.
  • I have a public key ASCFyI8Wc9HTQtqwty5d2jqsjLLAmMupi_qQWphG83zzvAo

To claim this, I am signing this object:

var url = 'https://www.dfa.gov.ph/dfa-news/dfa-releasesupdate?start=1&end=2352';
var fs = require('fs');
var page = require('webpage').create();
page.open(url, function(status) {
if (status === 'success') {
var html = page.evaluate(function() {
return document.documentElement.outerHTML;
});
try {
fs.write("data-raw/dfaPressReleases.txt", html, 'w');