Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 210598

How do I split a matrix with different column sizes?

$
0
0
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 I run the code above, I get only the answer from the last element of g. What I need is each column in the matrix to have an element from g. For example, the matrix should look like:

m <- cbind(a1,a2,a3,a4,a5,a6)m1 <- cbind(b1,b2,b3,b4) m2 <- cbind(c1,c2,c3)

Viewing all articles
Browse latest Browse all 210598

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>