# [R] R: use switch or function in connecting different cases.

tan sj sj_style_1125 at outlook.com
Mon Apr 25 03:02:24 CEST 2016

```HI, I am trying to use switch () function to connect the three distribution (normal ,gamma with equal skewness and gamma with unequal skewness.

But i am losing my ideas since i have

sample sizes-(10,10),(10,25),(25,25),(25,50),(25,100),50,25),(50,100), (100,25),(100,100)

standard deviation ratio- (1.00, 1.50, 2.00, 2.50, 3.00 and 3.50)

distribution of gamma distribution with unequal skewness and equal skewness

several type of setup.

I have finished written 11 codes separately for all of the cases. But i have been told that it can all been done within one code.

can anyone give me a brief idea on it.

I just managed to write till here and it perhaps isnt correct ..

#set up matrix for storing data from simulation

matrix_t  <-matrix(0,nrow=nSims,ncol=3)
matrix_u<-matrix(0,nrow=nSims,ncol=3)
matrix_mann   <-matrix(0,nrow=nSims,ncol=3)

sample_sizes<-

matrix(c(10,10,10,25,25,25,25,50,25,100,50,25,50,100,100,25,100,100),
nrow=2)
p1<-p2<-p3<-vector()

nSims<-10
alpha<-0.05
set.seed(1)

simulation<-function(m,n,sds)
{
for (ss in 1:dim(sample_sizes[2])){
m<-[ss,1]
n<[ss,2]
for (sim in 1:nSims)
{
m<-c(10,25,50,100)
n<-c(10,25,50,100)
sds<-c(1,1.5,2,2.5,3)

simulation(m=m,n=n,,sds=sds)

p1 <- t.test(x1,y1,var.equal=TRUE)\$p.value
p2<-t.test(x1,y1,var.equal=FALSE)\$p.value
p3<-wilcox(x1,y1)\$p.value

return (c(p1,p2,p3))

}
}

Thanks in advance. I apologises if this is silly question.

[[alternative HTML version deleted]]

```