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
grow <- function(x){diff(x)/x[-length(x)]} #a rate of change. | |
cont <- function(a,all){ #contribution | |
grow(a) * (a/all)[-length(a)] | |
} |
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
dat_somusho <- | |
structure(list(sex = structure(c(2L, 1L), .Label = c("female", | |
"male"), class = "factor"), `6-12` = c(1679437.5, 1743009.6), | |
`13-19` = c(2366812.5, 2450792.4), `20-29` = c(2352187.5, | |
2468424), `30-39` = c(2308312.5, 2415529.2), `40-49` = c(2327812.5, | |
2375228.4), `50-59` = c(2169375, 2057859.6), `60-64` = c(1925625, | |
1624626), `65-69` = c(1713562.5, 1377783.6), `70-79` = c(1464937.5, | |
974775.6), `80+` = c(975000, 445827.6)), .Names = c("sex", | |
"6-12", "13-19", "20-29", "30-39", "40-49", "50-59", "60-64", | |
"65-69", "70-79", "80+"), row.names = c("男性(n=24,375)", "女性(n=25,188)" |
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
crossbreed <- function(KW){ | |
dim1 <-dim(KW) | |
lis1 <- list() | |
for(i in 1:dim1[2]){ | |
lis1[[i]] <- KW[!is.na(KW[,i]),i] | |
} | |
lenv <- sapply(lis1,length) | |
#lenv | |
#lis1 | |
# out <- numeric(prod(lenv)) |
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
日の指標 | セッション | |
---|---|---|
2014/11/25 | 256 | |
2014/11/26 | 174 | |
2014/11/27 | 188 | |
2014/11/28 | 157 | |
2014/11/29 | 91 | |
2014/11/30 | 96 | |
2014/12/01 | 170 | |
2014/12/02 | 183 | |
2014/12/03 | 135 |
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
punc <- function(x){ | |
len = length(x) | |
pp <- which(x > 1.5*IQR(x) + quantile(x,3/4)) | |
pplen <- length(pp) | |
group <- rep(1,len) | |
group[pp] <- 1 | |
if(pplen==0){ | |
return(group) | |
break | |
} |
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 1 column, instead of 3. in line 5.
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
# ---------------------------------------- | |
# すべてのウェブサイトのデータ | |
# コンバージョン経路 | |
# 20141101-20150131 | |
# ---------------------------------------- | |
MCF チャネル グループの経路,コンバージョン数,コンバージョン値 | |
オーガニック検索 > ノーリファラー,22,$0.00 | |
ソーシャル ネットワーク > ノーリファラー,16,$0.00 | |
ソーシャル ネットワーク > ソーシャル ネットワーク,14,$0.00 |
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
"","channelGrouping","sessions","percentNewSessions","bounceRate","avgSessionDuration","pageviewsPerSession" | |
"1","(Other)",249,39.3574297188755,77.5100401606426,117.979919678715,1.61044176706827 | |
"2","Direct",1743,90.5909351692484,84.6242111302352,78.5100401606426,1.35226620768789 | |
"3","Organic Search",5703,84.5344555497107,84.7273364895669,58.9933368402595,1.28949675609328 | |
"4","Referral",2792,83.8467048710602,89.756446991404,44.6719197707736,1.24104584527221 | |
"5","Social",5193,79.3568264972078,85.7500481417293,56.7113421914115,1.32851916040824 |
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(ReacTran) | |
library(deSolve) | |
N <- 100 | |
xgrid <- setup.grid.1D(x.up = 0, x.down = 1, N = N) | |
x <- xgrid$x.mid | |
D.coeff <- 0.01 | |
Diffusion <- function (t, Y, parms){ | |
tran <- tran.1D(C = Y, C.up = 0, C.down = 1, | |
D = D.coeff, dx = xgrid) | |
list(dY = tran$dC, flux.up = tran$flux.up, |
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
waterfall <-function(left,right,group,leftname ="",rightname ="", | |
xlab="",ylab="",leftcol="grey80",rightcol="grey80",cols=NULL){ | |
sum1 =sum(left) | |
sum2 =sum(right) | |
tmp1 <- c(cumsum(c(sum1,right-left)),sum2) | |
len <-length(left) | |
bp <- barplot(c(sum1,rep(0,len),sum2), | |
space=0,yaxt="n",xaxt="n", | |
col=c(leftcol,rep("white",len),rightcol), | |
xlab=xlab,ylab=ylab) |
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
# circ1 <- function(x){ | |
# sqrt(1-x^2) | |
# } | |
# circ2 <- function(x){ | |
# -sqrt(1-x^2) | |
# } | |
# curve(circ1(x),xlim=c(-1,1),ylim=c(-1,1)) | |
# curve(circ2(x),xlim=c(-1,1),ylim=c(-1,1),add=TRUE) | |
# | |
theta = seq(0,2*pi,by=0.01) |