"0","sumarizator3 <- function(dt) {"
"0","  # Select relevant columns (from 10 to 110)"
"0","  dt <- dt[, 10:110]"
"0","  "
"0","  # Transpose the data"
"0","  tt <- t(dt)"
"0","  "
"0","  # Initialize matrix with appropriate dimensions (rows = columns of dt, columns = number of unique levels)"
"0","  mat <- matrix(0, nrow = nrow(tt), ncol = length(levels(as.factor(tt))))"
"0","  "
"0","  # Get the factor levels"
"0","  nivoi <- levels(as.factor(tt))"
"0","  "
"0","  # Set column names of matrix to the factor levels"
"0","  colnames(mat) <- nivoi"
"0","  rownames(mat) <- colnames(dt)"
"0","  "
"0","  # Loop through each row (question) and count occurrences of each level"
"0","  for (i in 1:nrow(tt)) {"
"0","    level_counts <- summary(as.factor(tt[i, ]))"
"0","    "
"0","    # Loop over each factor level and populate the matrix"
"0","    for (level in nivoi) {"
"0","      mat[i, level] <- level_counts[level]"
"0","    }"
"0","  }"
"0","  "
"0","  # Replace NA values with 0"
"0","  mat[is.na(mat)] <- 0"
"0","  return(mat)"
"0","}"
"0",""
