Skip to content

Instantly share code, notes, and snippets.

View stephlocke's full-sized avatar

Steph Locke stephlocke

View GitHub Profile
library(xml2)
orig<-read_xml("https://itsalocke.com/sitemap-1.xml")
xml_find_all( orig,"//loc")
@stephlocke
stephlocke / cyphr.md
Last active July 26, 2017 19:11
Review of the cyphr package

Package Review

Please check off boxes as applicable, and elaborate in comments below. Your review is not limited to these topics, as described in the reviewer guide

  • As the reviewer I confirm that there are no conflicts of interest for me to review this work (If you are unsure whether you are in conflict, please speak to your editor before starting your review).

Documentation

The package includes all the following forms of documentation:

myString<-"Hey Steph!"
a<-50:1
a[1:5]
a[a<25]
a[-1]
a[-(40:50)]
a[c(FALSE,TRUE)]
b<-c(11:50,1:10)
b[b %% 2]
b[as.logical(b %% 2)]
This post provides an overview of performing diagnostic and performance evaluation on logistic regression models in R. After training a statistical model, it’s important to understand how well that model did in regards to it’s accuracy and predictive power. The following content will provide the background and theory to ensure that the right technique are being utilized for evaluating logistic regression models in R.
Logistic Regression Example
We will use the GermanCredit dataset in the caret package for this example. It contains 62 characteristics and 1000 observations, with a target variable (Class) that is allready defined. The response variable is coded 0 for bad consumer and 1 for good. It’s always recommended that one looks at the coding of the response variable to ensure that it’s a factor variable that’s coded accurately with a 0/1 scheme or two factor levels in the right order. The first step is to partition the data into training and testing sets.
```
library(caret)
data(GermanCredit)
Train <- cr
@stephlocke
stephlocke / readallsheets.R
Last active July 20, 2017 14:17
Example of reading all tabs in a google spreadsheet
library(googlesheets)
library(purrr)
library(data.table)
library(magrittr)
suppressMessages(gs_auth(token = "c:\\Users/steph/Documents/googlesheets_token.rds", verbose = FALSE))
mySheet<-"https://docs.google.com/spreadsheets/d/1QfvTK58YO7kBIzI81JQ7rNLcTVbH0hDiP6qZ724GyoA/edit?usp=sharing"
mySheet %>%
gs_url() %>%
gs_ws_ls() %>%
@stephlocke
stephlocke / detaildata.csv
Created July 17, 2017 14:43
Analysing the PASS budget
LineItem B2016 B2017 TblChange Total Net Title Type Dept IgnoreRow
Gain/Loss on Revaluation of Euro 0 0 3 FALSE FALSE FALSE Revenue Corporate Administration FALSE
Interest - Miscellaneous 11e3 11e3 3 FALSE FALSE FALSE Revenue Corporate Administration FALSE
Misc FY Adjustments 0 0 3 FALSE FALSE FALSE Revenue Corporate Administration FALSE
Unrealized Gain/Loss on Investments 0 0 3 FALSE FALSE FALSE Revenue Corporate Administration FALSE
Accounting - General 3500 5e3 4 FALSE FALSE FALSE Expense Corporate Administration FALSE
Annual Report 37 37 4 FALSE FALSE FALSE Expense Corporate Administration FALSE
Audit 25e3 25e3 4 FALSE FALSE FALSE Expense Corporate Administration FALSE
Authorize.Net Fees 1e3 1e3 4 FALSE FALSE FALSE Expense Corporate Administration FALSE
Bank Charges 9e3 9e3 4 FALSE FALSE FALSE Expense Corporate Administration FALSE
@stephlocke
stephlocke / mylittleapp.Rmd
Created July 14, 2017 16:06
A quick app built showing how to make sliders and interactive charts!
---
title: "Untitled"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
@stephlocke
stephlocke / DiagrammeR.R
Last active July 10, 2017 10:54
Trying to make a staff hierarchy in DiagrammeR
library(dplyr)
library(readr)
library(DiagrammeR)
staff <- read_csv(
"ID,Name,Title,ManagerID
1,Jane,CEO,
2,Bill,CIO,1
3,Lydia,CTO,1
4,Jack,CMO,1
library(dplyr)
library(readr)
library(DiagrammeR)
staff <- read_csv(
"ID,Name,Title,ManagerID
1,Jane,CEO,
2,Bill,CIO,1
3,Lydia,CTO,1
4,Jack,CMO,1