[Solved] Take one sample per row at a time, compute mean, loop [closed]

First lets make so data to experiment with set.seed(100) example <- matrix(runif(47*30), nrow = 47) example[sample(length(example), 250)] <- NA Now we can calculate our means. The apply function samples a random value from each row (!is.na excludes NA values), mean gets the mean, and replicate repeats this 10000 times. exmeans <- replicate(10000, mean(apply(example, 1, function(x) … Read more