How to do calculations on elements from a sublist in R -


my code follows:

x <- data.frame(matrix(rnorm(20), nrow=10)) colnames(x) <- c("z", "m") n_boot<-4 bs <- list()  (i in 1:n_boot) {  bs[[i]] <- x[sample(nrow(x), 10, replace = true), ] }  bt<-matrix(unlist(bs), ncol = 2*n_boot, byrow = false) colnames(bt) <- rep(c("z","m"),times=n_boot) m_to_boot <- bt[,seq(2,8,by=2)]  funct<-function(m_boot_max) {      od<-(1/((10*((10^((16-m_boot_max-25)/5))^3)/3)*((max(m_boot_max)-min(m_boot_max))/50))) } v_boot<-apply(m_to_boot,2,funct)  rows.combined <- nrow(m_to_boot)  cols.combined <- ncol(m_to_boot) + ncol(v_boot) matrix.combined <- matrix(na, nrow=rows.combined, ncol=cols.combined) matrix.combined[, seq(1, cols.combined, 2)] <- m_to_boot matrix.combined[, seq(2, cols.combined, 2)] <- v_boot colnames(matrix.combined) <- rep(c("m_boot","v_boot"),times=n_boot)  df<-as.data.frame(matrix.combined) start0 <- seq(1, = 2, length = ncol(df) / 2) start <- lapply(start0, function(i, df) df[i:(i+1)], df = df)  tests<-lapply(start, function(xy) split(xy, cut(xy$m_boot,breaks=5))) 

now want prepare calculations on values v_boot sublists. specific want each subsample calculate sum of v_boot. so, example want bin m_boot "[[4]]$(0.811,1.25]" have value of sum(v_boot) bin. cannot figure out how each v_boot values.

please me.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -