Skip to content

Instantly share code, notes, and snippets.

View IronistM's full-sized avatar
🏗️
Under construction

Manos Parzakonis IronistM

🏗️
Under construction
View GitHub Profile
###############################################################################
Description: A set of R functions to implement the Independent RFM scoring and the RFM scoring with input breaks.
Author: Jack Han http://www.DataApple.net email: jackhan2008 # qq.com
Version: 1.3
Date: 23 Dec 2013
Usage: Read the article "RFM Customer Analysis with R Language" http://www.dataapple.net/?p=84
################################################################################
################################################################################
@IronistM
IronistM / time_dims_splunk.sql
Created December 24, 2013 12:40
Time dimensions extracting in #Splunk
# weeknum
eval wnum=strftime(_time, "%V")
# DayOfWeek
eval DayOfWeekC=strftime(_time, "%a")
# hour
eval hour=strftime(_time,"%H:00")
# date in format %y-%m-%d, eg. 13-12-17
eval Date=strftime(_time, "%y-%m-%d")
@IronistM
IronistM / NumLeft.vbs
Created December 24, 2013 09:31
Extract numbers from the start or end of text strings. from http://wp.me/pc8LR-1mA "It’s not too hard to do with on-sheet formulas, but after having done it a few thousand times I decided it would be worth spending 5 minutes writing two VBA User Defined Functions (UDFs) to do the job. Here they are: NumRight() will extract a number from the righ…
Function NumLeft(NumStrings As Variant, Optional Delim As String = " ") As Variant
Dim i As Long, numrows As Long, OutA() As Variant, j As Long, NumDig As Long, Numstring As String, StringLen As Long
If TypeName(NumStrings) = "Range" Then NumStrings = NumStrings.Value2
If TypeName(NumStrings) = "String" Then
numrows = 1
Else
numrows = UBound(NumStrings)
End If
@IronistM
IronistM / standardize_name.r
Created December 10, 2013 09:45
standardize names #rstats
# Function to clean names
standardize_name <- function(string) {
capped <- grep("^[^A-Z]*$", string, perl = TRUE)
substr(string[capped], 1, 1) <- toupper(substr(string[capped], 1, 1))
# string <- gsub('_',' ',string, fixed=TRUE)
return(string)
}
# There are several domain name servers that allow
# for bulk searching of domain names.
# http://www.godaddy.com/bulk-domain-search.aspx
# http://www.namestation.com/bulk-domain-search
# However, they do not provide any wildcard support
# and instead expect users to supply their own list.
# Which is not a problem if you are an R coder.
# This single command will copy to the clipboard a list
# of mysite1 mysite2 mysite3....mysite500. You can then
# Load bare essentials
library("ggplot2")
library("plyr")
library("reshape2")
library("timeSeries")
library("TTR")
library("forecast")
# Things you might want to change
@IronistM
IronistM / save an R dataframe with the name specified by a string.r
Created November 29, 2013 13:13
save an R dataframe with the name specified by a string
# Create explicit data frames and TS objects given a list
market.list<- c("GR","CY","RU","RO","PL","UA","ROW")
for (i in market.list) {
tmp <- subset(data,Market==i)
tmp<-ts(tmp) # It's a timeseries afterall...
# Let's save the data somewhere so we don't get back all the time
filename <- paste("data_", i, sep="")
assign(filename, tmp)
save(filename, file=paste(filename, ".rda",sep=""))
}
dic <- data.frame(old = c("cat", "dog", "coffee", "tea", "tee"), new = c("kissa", "koira", "kahvi", "tee", "tii"))
sapply( unique(as.character(dic$old)) , function(i) { test.words[as.character(test.words) == i] <<- as.character(dic$new[as.character(dic$old) == i]) })
test.words
require(fpp)
# Please make sure at least v3.10 of the forecast is loaded
# before running these examples.
# Three examples
beer <- aggregate(ausbeer)
plot(beer)
plot(a10)
plot(taylor)
@IronistM
IronistM / Qliktech Set Analysis
Created November 18, 2013 15:39
Qliktech Set Analysis
!TCL=4,
!TITLE=Qliktech Set Analysis
!SORT=N
!CHARSET=ANSI
!TEXT=Month To Date Last Year
=sum({$<CAL_YEAR={$(=max(CAL_YEAR)-1)},CAL_DATE = {"<=$(=addmonths(max(CAL_DATE),-12))"},CAL_MONTH={"=$(=max(CAL_ MONTH))"}>} SALES))
!