How to split the matrix in r with different size column sizes -
n <- c(12,24) mu<-c(6.573,6.5) sigma<-sqrt(0.25) diseased.data<-round(rnorm(n[1], mu[1], sigma), 4) healthy.data<-round(rnorm(n[2], mu[2], sigma), 4) g <- c(2,3,4) for(i in 1:3){ pool.dis.data <- matrix(na,n[1]/g[i],n[1]/g[i]) for(j in n[1]/g[i]){ pool.dis.data <- replicate(n[1]/g[i],mean(sample(diseased.data,g[i]))) } }
when run code, answer last element of g. need each columns matrix should have element each element in g, example matrix should m<- cbind(a1,a2,a3,a4,a5,a6), m1 <- cbind(b1,b2,b3,b4), m2<- cbind(c1,c2,c3)
Comments
Post a Comment