Create tables by grouping variable

Hi,

I have a dataset from limesurvey, containing different variables from likert scales and some of the variables depend to a grouping variable, e.g:

Question A:
I visited the following workshop:
[list of 8, select one of them]
Workshop 1
Workshop 2
...
Workshop 8

Question B:
[likert items with 4 choices "yes (++), more yes (+), more no (-), no (--)"]

  1. I liked the workshop.
  2. I learned a lot.
  3. The teacher was brilliant.
  4. I need more input.
  5. The given materials were useful.

Now I want to create a result table for every Workshop.

Results Workshop 1:

Item yes (++) more yes (+) more no (-) no (--)
1. I liked the workshop. 10 5 1 1
2. I learned a lot. 5 10 2 0
3. The teacher was brilliant. 1 10 5 1
4. I need more input. 1 1 10 5
5. The given materials were useful. 10 1 5 1

Used code to create the table:

data <- read.csv("C:/Users/.../survey_515378_R_data_file.csv", quote = "'\"", na.strings=c("", "\"\""), stringsAsFactors=FALSE, fileEncoding="UTF-8-BOM")

# LimeSurvey Field type: A
data[, 18] <- as.character(data[, 18])
attributes(data)$variable.labels[18] <- "I visited the following workshop:"
data[, 18] <- factor(data[, 18], levels=c("1","2","3","4","5","6","7","8"),labels=c("Workshop 1", "Workshop 2", "Workshop 3", "..."))
names(data)[18] <- "Workshop"

# LimeSurvey Field type: F
data[, 20] <- as.numeric(data[, 20])
attributes(data)$variable.labels[20] <- "I liked the workshop."
data[, 20] <- factor(data[, 20], levels=c(0,1,2,3),labels=c("no\n(--)", "more no\n(-)", "more yes\n(+)", "yes\n(++)"))
names(data)[20] <- "I liked the workshop."



#With the following code I create the table without the grouping variable from question A


W <- mapply(table, data[, 20:24]); W
W <- t(W)
W <- round((W/rowSums(W))*100,0)

W2 <- as.data.frame(W) %>%
  tibble::rownames_to_column("Results Workshop")

TableW <- flextable(W2) %>%
    width(j = 1, width = 12, unit = "cm") %>%  width(j = 2:5, width = 1, unit = "cm")

theme_zebra(TableW, odd_header = "#87ceeb",  odd_body = "transparent",  even_header = "transparent",  even_body = "#d1eeee")
ยดยดยด

**So my question: How can I create this table for every single Workshop (from Question A)?
I would like to have this table for every workshop. It's possible that some of the given Workshops (options in question A) contain no results or that the list can be longer than 5 items when repeating the questionnaire some weeks later.**