A quick script to explore one of the options for using command line args for an R script.
https://twitter.com/BrockTibert/status/1076844910022660096
- good quick review: -- http://blog.sellorm.com/2017/12/30/command-line-utilities-in-r-pt-6/
| --- | |
| title: Tensorflow, Tip-Ins, and Tableau, Oh My | |
| author: Brock Tibert | |
| date: '2020-02-18' | |
| slug: tensorflow-tip-ins-and-tableau-oh-my | |
| categories: | |
| - R | |
| tags: | |
| - NHL | |
| - Tensorflow |
| # timestamp tz conversion | |
| DATE = "2020-01-23 13:23:45" | |
| lubridate::ymd_hms(DATE) | |
| ts = lubridate::ymd_hms(DATE, tz = "America/Los_Angeles") | |
| ts | |
| lubridate::with_tz(ts, tzone = "America/New_York") | |
| ts_eastern = lubridate::with_tz(ts, tzone = "America/New_York") | |
| lubridate::with_tz(ts, tzone = "UTC") | |
| utc = lubridate::with_tz(ts, tzone = "UTC") | |
| as.character(utc) |
| ## function to take an dendrogram, and heights for each iteration | |
| ## pull out the # of clusters and height | |
| hclust_eval = function(c) { | |
| # extract the height, and the dendrogram | |
| h = c$height | |
| d = as.dendrogram(c) | |
| # the container for the stats | |
| s = list() | |
| # for each entry in h, get the # of clusters | |
| # TODO: improve this code |
| name: r_env | |
| channels: | |
| - conda-forge | |
| - defaults | |
| dependencies: | |
| - _r-mutex=1.0.1=anacondar_1 | |
| - appnope=0.1.0=py37_1000 | |
| - attrs=19.2.0=py_0 | |
| - backcall=0.1.0=py_0 | |
| - bleach=3.1.0=py_0 |
| options(stringsAsFactors = FALSE) | |
| #################### setup | |
| ## define the vectors | |
| poker_vector <- c(140, -50, 20, -120, 240) | |
| roulette_vector <- c(-24, -50, 100, -350, 10) | |
| ## we are covering named vectors in the module 3 Friday |
A quick script to explore one of the options for using command line args for an R script.
https://twitter.com/BrockTibert/status/1076844910022660096
This R script provides a helper function to take a dataframe, and build a proper
rasa NLU training file in JSON format. This would be helpful for when you want to:
| # Calculate age at a given reference date | |
| # Create an interval between the date of birth and the enrollment date; | |
| # intervals are specific to the two dates. Periods give the actual length | |
| # of time between those dates, so convert to period and extract the year. | |
| calc_age <- function(birthDate, refDate = Sys.Date()) { | |
| require(lubridate) |