This file contains 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
#-- BASED ON https://cloud.google.com/vision/docs/request#json_request_format --# | |
# image url on Google Cloud Storage | |
imgURI <- "gs://vacation_room/dublin-001.jpg" | |
# Requests are POST requests to | |
endpoint <- "https://vision.googleapis.com/v1/images:annotate" | |
#### remember to set api token in ``options`` | |
# options(gcv_api_token = "YOUR_API_TOKEN") |
This file contains 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(shiny) | |
ui <- fluidPage( | |
column(12, | |
# toggle between normal or uniform distribution | |
actionButton("rnorm", "Normal"), | |
actionButton("runif", "Uniform") | |
), | |
column(12, | |
plotOutput("plot") |
This file contains 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
# Generate dummy data ----------------------------------------------------- | |
library(dplyr) | |
library(ggplot2) | |
library(lubridate) | |
start_day <- as.Date("2018-01-01") | |
# 2 Columns - Date & n | |
dat <- data.frame(date = start_day + days(1:90), n = round(runif(90, 1, 10))) |
This file contains 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
#!/bin/bash | |
# Header | |
echo `date` | |
if [ -d .git ];then | |
echo -e "\n\033[0;42m **** Current Status ****\033[0m\n" | |
git status -s | |
echo -e "\n\033[0;43m **** Pending Issue ****\033[0m\n" |
This file contains 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
#!/bin/bash | |
function _awsSwitchProfile() { | |
# Check if argument exists | |
if [ -z $1 ]; then echo "Usage: _awsSwitchProfile <profilename>"; return; fi | |
# Check if profile exists | |
exists="$(aws configure get aws_access_key_id --profile $1)" |
This file contains 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
#!/bin/bash | |
BUCKET="rdata" | |
if [[ -z $1 ]]; then | |
aws s3 ls s3://$BUCKET | |
elif [ $1 = "-u" ]; | |
then | |
echo "Encrypting data..." | |
OBJ=$(ccrypt -e $2 -K "qwer" -f -q) |
This file contains 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
# China Outbound Tourism | |
library(readxl) | |
library(tidyr) | |
library(ggplot2) | |
library(broom) | |
# read data | |
cot <- read_excel("~/Downloads/outbound_tourism_china.xlsx", skip = 5) | |
# mod columns name | |
colnames(cot) <- c("country", "series", 1995:2016, "pct_chg_16_15") |
This file contains 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
# Reference | |
# http://www.x-rates.com/average/?from=CNY&to=EUR&amount=100&year=2017 | |
library(rvest) | |
# | |
base <- "http://www.x-rates.com/average/?amount=100" | |
# Currency | |
cur <- c("USD", "CNY") |
This file contains 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 Rscript --vanilla | |
args <- commandArgs(trailingOnly = TRUE) | |
# List all files | |
items <- list.files(path = ".") | |
# See which matches argument (regex) | |
old <- items[grep(items, pattern = args[1])] |
This file contains 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(readxl) | |
library(tidyr) | |
library(ggplot2) | |
library(broom) | |
library(rvest) | |
library(plotly) | |
# Import data ------------------------------------------------------------- |
OlderNewer