Skip to content

Instantly share code, notes, and snippets.

View StevenMMortimer's full-sized avatar

Steven M. Mortimer StevenMMortimer

View GitHub Profile
library(shiny) #shiny_0.11.1.9005
library(DT) #DT_0.0.41
# create sample table
data <- matrix(1:200000, ncol = 4, dimnames=list(NULL, c("Row Index", "V1", "V2", "V3")))
ui = shinyUI(
fluidPage(
fluidRow(
column(1),
Automate Chunks of Analysis in R Markdown
========================================================
```{r setup, echo=FALSE}
library(knitr)
library(DT)
```
```{r create-datasets, echo=FALSE}
Automate Chunks of Analysis in R Markdown
========================================================
```{r setup, echo=FALSE}
library(knitr)
library(DT)
```
```{r create-datasets, echo=FALSE}
library(plyr)
#testing gist change
#LLPLY
# Create a list with 2 elements
l <- list(a = 1:10, b = 11:20, c=21:30, d=31:40)
# Apply a function to each element of the list
system.time(lapply(l, mean))
library(RForcecom)
library(XML)
library(RCurl)
username <- "YOURS"
password <- "YOURS"
instanceURL <- "YOURS"
apiVersion <- "34.0"
session <- rforcecom.login(username, password, instanceURL, apiVersion)
library(devtools)
install_github('ReportMort/leaflet')
library(leaflet)
m <- leaflet()
m <- addTiles(m)
m <- addMarkers(m, lng=174.768, lat=-36.852, popup="The birthplace of R", layerId='layer1')
m <- addMarkers(m, lng=174.788, lat=-36.852, popup="East of the birthplace of R", layerId='layer2')
m
# test toggle open
library(shiny)
#library(devtools)
#install_github('ReportMort/leaflet')
library(leaflet) # note forked version is needed on local machine in order to run
points <- data.frame(lng=rnorm(10) * 2 + 13,
lat=rnorm(10) + 48,
popup=paste('Popup #', 1:10),
layerId=as.character(1:10))
# travis encrypted vars don't seem to work on Windows machines, so if you need them, create a virtualbox (I'm running ubuntu here)
# and install travis CLI tools in order to encrypt them and add to your repo
# setup virtual machine running ubuntu, here is the vagrant script
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "4048"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
# deleting tracking events based on a filter
# this example deletes any "simple_tracking" events with an ipdetail.ip equal to 777.888.99.00 within the last 7 days
curl "https://api.keen.io/3.0/projects/{project_key_goes_here}/events/simple_tracking?filters=%5B%7B%22property_name%22%3A%22ipdetail.ip%22%2C%22operator%22%3A%22eq%22%2C%22property_value%22%3A%22777.888.99.00%22%7D%5D&timeframe=this_7_days" \
-H "Authorization: {secret_key_goes_here}" \
-X DELETE
# deleting between two dates
# this uses the R software to convert the json string to the URL encoding as seen in the curl command
str <- '[{"property_name":"app_name","operator":"eq","property_value":"my-app"}, {"property_name":"keen.created_at","operator":"gt","property_value":"2015-10-10T00:00:00-0400"}, {"property_name":"keen.created_at","operator":"lt","property_value":"2015-10-09T09:00:00-0400"}]'
gsub('-', '%2D', URLencode(str, reserved = T))
remove.packages('leaflet', '/usr/local/lib/R/site-library')
with_libpaths(new='/usr/local/lib/R/site-library', install_github('ReportMort/leaflet'))