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

for loop in R — generating and calculate different results

$
0
0

Giving rnorm(100) I need to create a for loop in R to calculate the mean and the standard deviation generating 100 different numbers each time, and store those results in a vector.

How can I accomplish that?

so far

a <- rnorm(100) # generate 100 random numbers with normal distribution

sample <- 100 # number of samples
results <- rep(NA, 100) # vector creation for storing the results

for (i in 1:sample){
results[i] <- as.data.frame() # then i stuck here, lol, the most important part
}

Viewing all articles
Browse latest Browse all 201839

Trending Articles



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