repeat sample in r

# Set a seed for reproducibility
set.seed(123)

# Specify the number of repetitions
num_reps <- 5

# Specify the size of each sample
sample_size <- 10

# Create an empty vector to store the results
results <- numeric()

# Repeat the sampling process
for (i in 1:num_reps) {
  # Generate a random sample
  current_sample <- sample(1:100, size = sample_size, replace = TRUE)

  # Summarize or process the current sample (for demonstration purposes, just printing the sample)
  print(current_sample)

  # Store the results (for demonstration purposes, storing the mean of each sample)
  results <- c(results, mean(current_sample))
}

# Display the final results
print(results)

Note: Replace the content inside the loop with the actual processing or analysis you want to perform on each sample. The example provided simply prints each sample and calculates the mean of each sample for demonstration purposes.