-
Drawn mostly from:
http://www.rstudio.com/products/rstudio/download-server/
-
ssh into the instance.
-
Install any outstanding updates
sudo yum update
-
Install R:
sudo yum install R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(curl) | |
library(XML) | |
listFiles <- function(username, password, relPath = "/", dav = "https://dav.box.com/dav") { | |
uri <- URLencode(paste(dav, relPath, sep="")) | |
# fetch directory listing via curl and parse XML response | |
h <- new_handle() | |
handle_setopt(h, customrequest = "PROPFIND") | |
handle_setopt(h, username = username) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Testing a three way IPF with combined and individual marginals. | |
library(mipfp) | |
library(dplyr) | |
pers <- data_frame( | |
gender = sample(c("m","f"),25,replace = T), | |
age = rep(1:5,5), | |
fpl = rep((5:1)/0.5,5), | |
w = rep(1,25) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"intents": [ | |
{ | |
"intent": "GetNewFactIntent" | |
}, | |
{ | |
"intent": "AMAZON.HelpIntent" | |
}, | |
{ | |
"intent": "AMAZON.StopIntent" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Multiply the columns of the data frame by the elements of the vector" | |
output: html_notebook | |
--- | |
Matrix: | |
```{r} | |
(mat <- matrix(c(4:9),ncol = 2)) | |
``` |
This gist shows how to convert a nested JSON file to an R data.frame. To do this, it uses jsonlite and data.tree.
The gist contains two examples: one is a bit simpler, the second one a bit more advanced.
In the first example, we download all the repos from Hadley Wickham's Github account from https://api.github.com/users/hadley/repos . This JSON contains a nested owner object. The code shows how to convert that in a flat data.frame in three statements:
- line 5: download
- line 8: convert to data.tree
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> | |
<script src="delphi-nij.js"> </script> | |
<link rel="stylesheet" type="text/css" href="delphi-nij.css"> | |
<title>NIJ PCJNI Delphi</title> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
if __name__ == '__main__' and len(sys.argv) > 5 and sys.argv[1][-3:].upper() == 'PDF': | |
original = sys.argv[1] | |
target = original[:-4] + '.cropped.pdf' | |
left = int(sys.argv[2]) | |
top = int(sys.argv[3]) | |
right = int(sys.argv[4]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* I add this to html files generated with pandoc. | |
*/ | |
html { | |
font-size: 100%; | |
overflow-y: scroll; | |
-webkit-text-size-adjust: 100%; | |
-ms-text-size-adjust: 100%; | |
} |