Entries
Phillips Hue in R
The following function can be used to find and display the internal IP address needed to retrieve the IP address from Hue Bridge. You will need to generate an API key i.e. a “userkey” as I called it below. getIP <- function() { url <- paste0("https://www.meethue.com/api/nupnp") res <- httpGET(url) resJson <- fromJSON(res) res <- resJson[["internalipaddress"]] res } In order to know what light you should change the state on, one can run the following to retrieve the available lights connected on the network.
August 7, 2018
Simulate Doctor Visit Resource Planning Using Simmer
Here I’ve tried to come up with a simple layout on how we might simulate doctor’s visits. Following code tries to resource plan certain doctor visits based on the vignette that was provided with the simmer package. library(simmer) set.seed(42) env <- simmer("SuperDuperSim") env patient <- trajectory("patients' path") %>% ## add an intake activity seize("nurse", 1) %>% timeout(function() rnorm(1, 15)) %>% release("nurse", 1) %>% ## add a consultation activity seize("doctor", 1) %>% timeout(function() rnorm(1, 20)) %>% release("doctor", 1) %>% ## add a planning activity seize("administration", 1) %>% timeout(function() rnorm(1, 5)) %>% release("administration", 1) env %>% add_resource("nurse", 1) %>% add_resource("doctor", 2) %>% add_resource("administration", 1) %>% add_generator("patient", patient, function() rnorm(1, 10, 2)) env %>% run(80) %>% now() env %>% peek(3) env %>% stepn() %>% # 1 step print() %>% stepn(3) # 3 steps envs <- lapply(1:100, function(i) { simmer("SuperDuperSim") %>% add_resource("nurse", 1) %>% add_resource("doctor", 2) %>% add_resource("administration", 1) %>% add_generator("patient", patient, function() rnorm(1, 10, 2)) %>% run(80) }) envs %>% get_mon_resources() %>% head() envs %>% get_mon_arrivals() %>% head()
August 7, 2018
Take Back Your Time (Evernote)
You will find the following text originally posted on Medium
August 7, 2018
Time and Difficulty
Sometimes, seeing data in a 3 dimensional space gives us better visibility to the rest of the world. You will see that we have taken a hypothetical experiment and tried to rate different ideas by their complexity and likelihood to succeed. #Libraries to import library(tidyverse) library(plotly) # Intellectual matrix idea <- c("Build a spaceship","Create a new social platform", "Build a birdhouse","Collect 10000 friends", "Clip toenails","Build a spaceship","Create a new social platform", "Build a birdhouse","Collect 10000 friends","Build a spaceship","Create a new social platform", "Build a birdhouse","Collect 10000 friends","Build a spaceship","Create a new social platform", "Build a birdhouse","Collect 10000 friends") time <- c(5,5,2,3,1,5,5,2,3,5,5,2,3,1,5,5,2) difficulty <- c(5,4,2,3,1,5,4,2,3,5,5,2,3,1,5,5,2) favorability <- c(2,5,2,1,3,4,1,2,1,2,5,2,1,3,3,1,2) #Creates the dataframe dataset <- data.frame(Idea = idea, Time = time, Difficulty = difficulty, Favorable = favorability) # Creates the 3 dimension intellectual plot p <- plot_ly(dataset, x = ~Time, y = ~Difficulty, z = ~Favorable, color = ~Idea) %>% add_markers() %>% layout(title = "Intellectual Matrix", scene = list(xaxis = list(title = 'Length to Complete'), yaxis = list(title = 'Difficulty'), zaxis = list(title = 'Likability'))) p
August 7, 2018
Minature Generative Art
Sometimes something simple can turn out to generate the most beautiful things. Following you will find a few lines of code that present a beautiful pattern. library(ggplot2) library(dplyr) Oval Curve n <- 300 t1 <- 1:n t0 <- seq(3,2*n+1,2) %% n t2 <- t0 + (t0 == 0)*n df <- data.frame(x = cos((t1-1)*2*pi/n), y = sin((t1-1)*2*pi/n), x2 = cos((t2-1)*2*pi/n), y2 = sin((t2-1)*2*pi/n)) ggplot(df,aes(x,y,xend = x2,yend = y2)) + geom_segment(alpha = .1) + theme_void() Wavy Weaving of Wonder seq(from=-10, to=10, by = 0.05) %>% expand.grid(x=., y=.) %>% ggplot(aes(x=(x+pi*sin(y)), y=(y+pi*sin(x)))) + geom_point(alpha=.1, shape=20, size=1, color="black")+ theme_void()
January 8, 2018
Extracting Hyperlinks from an XSLX in R
In Progress install.packages("keras") library(keras) devtools::install_github("omarwagih/ggseqlogo") devtools::install_github("leonjessen/PepTools")
January 4, 2018
Human Ingenuity and Speed
library(tidyverse) Data Building The first thing we need to understand is where we have come and where we are going. There is alot that has been done in the past couple years but we still have more.
December 23, 2017
Words With Friends Musings
Words with Friends is a wonderful game full of #library(tidyverse) # IMport Data #filepath <- "~/Dropbox/Word Lists/WordsWithFriends/enable1-wwf-v4.0-wordlist.txt" #wwfList <- read_csv(filepath, col_names = FALSE) #wwfList %>% stringr::str('.ae.')
December 3, 2017
Exploring the Book of Esther in the Tidy Verse
library(httr) library(tidytext) library(jsonlite) library(tidyverse) library(wordcloud) library(XML) source("~/keys.R") key <- biblia There is much to be learned in the form of writing and the relationship it has within and outside the text. The question we might want to ask is there a way to identify the story arc of the situation. Using spacy to tag all of the words will increase the likelyhood to better understand the
November 30, 2017
Timeseries Analysis Using R and Advantager
Threw error due to the API In the past, the best way to get stock prices was to use either Google Finance or Yahoo Finance data streams. These have since become difficult to keep up to date and thus another outlet to get this information is AlphaVantager. Following is a simple R implementation to get up to date data. You will be able to thus use this to find the information.
November 11, 2017