# Set seed for reproducibility
set.seed(123)
# Define the number of iterations
n_iterations <- 10000
# Define the categories and their percentages
categories <- c("dispos", "disneg", "nodisneg", "nodispos")
percentages <- c(71.25, 3.75, 24.5, 0.5)
# Convert percentages to probabilities
probabilities <- percentages / 100
# Initialize a data frame to store the results
results <- data.frame(
Iteration = integer(n_iterations),
Category = character(n_iterations),
stringsAsFactors = FALSE
)
# Assign points to categories based on the specified probabilities
for (i in 1:n_iterations) {
results$Iteration[i] <- i
results$Category[i] <- sample(categories, size = 1, prob = probabilities)
}
# View the first few rows of the results
head(results)
## Iteration Category
## 1 1 dispos
## 2 2 nodisneg
## 3 3 dispos
## 4 4 nodisneg
## 5 5 nodisneg
## 6 6 dispos
# Optionally, you can summarize the counts of each category
summary_table <- table(results$Category)
print(summary_table)
##
## disneg dispos nodisneg nodispos
## 343 7167 2444 46