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(ggplot2) | |
library(dplyr) | |
electrial_consumption <- tibble::tribble( | |
~country, ~pct, | |
"Italy", -27, | |
"Spain", -21, | |
"Belgium", -17, | |
"Austria", -16, | |
"France", -16, |
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
Sub HyperlinkWorksheetNames() | |
'Code by Deep Dave, makes a Table of Content on a new sheet named Index | |
'Check out some helpful Excel blogs on www.NeedForExcel.com | |
Dim R() As Variant, WS As Worksheet, i As Byte, Counter As Integer, LR As Integer | |
On Error Resume Next 'If the Worksheet named Index does not exist, this will ignore the generated error | |
Application.DisplayAlerts = False 'Display alerts when set to false, will not ask confirmation |
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
#### Source this from github using following link #### | |
# devtools::source_gist("https://gist.github.com/martinctc/53444d4847055a870417f5b279f1b8bd", filename="surveyr.R") | |
#' Calculate weight table using a single source/target column | |
#' (indicating what proportions need to be multiplied to achieve weighted proportions) | |
#' | |
#' @param x Data frame containing columns to be weighted | |
#' @param target bare (unquoted) column name of the variable used for creating weight | |
#' @param weights vector containing the proportions of what each value of the target column should take |
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(tidyverse) | |
library(ggalt) # devtools::install_github("hrbrmstr/ggalt") | |
df <- data_frame( | |
benchmark=c(0.52, 0.57, 0.60, 0.63, 0.64, 0.67), | |
referrals=c(4.2, 4.5, 4, 4.5, 3.9, 3.6), | |
year=c(2011, 2012, 2013, 2014, 2015, 2016) | |
) | |
# as of 2016-11-07 ggplot2 geom_label() seems to be ignoring the "angle" parameter, hence the non-ideal use of geom_text() |
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) | |
library(tm) | |
library(SnowballC) | |
library(randomForest) | |
options(mc.cores=1) | |
build_model <- function(new_data_df, sparsity) { | |
# Create new data corpus | |
new_corpus <- Corpus(VectorSource(new_data_df$Text)) |
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
Sub Macro1() | |
findArray = Array("/01/", "/02/", "/03/", "/04/", "/05/", "/06/", "/07/", "/08/", "/09/", "/10/", "/11/", "/12/") | |
replArray = Array("/Jan/", "/Feb/", "/Mar/", "/Apr/", "/May/", "/Jun/", "/Jul/", "/Aug/", "/Sep/", "/Oct/", "/Nov/", "/Dec/") | |
For i = 0 To UBound(findArray) | |
Selection.EntireColumn.Select | |
Selection.Replace What:=findArray(i), Replacement:=replArray(i), LookAt:=xlPart, _ | |
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ | |
ReplaceFormat:=False |