I have this adjacency table which we can call df. I want to find a programmatic way to take this table and convert it for use in the seminr package.
#Example of my data
df <- read.table(text = " from to column_position
1 a V7 11
2 b V7 15
3 c V7 10
4 a V7 9
5 b V7 12
6 c V16 17
7 a V16 5
8 b V16 27
9 c V16 6
10 a V16 20
11 b V16 14
12 c V16 7
13 a V14 19
14 b V14 18
15 c V20 24
16 a C5 21
17 b C5 28
18 c C13 22
19 a C13 23
20 b C16 26
21 c C16 16
22 a C16 25
23 b C15 8
24 c C15 13", header = TRUE)
Typically in seminr you would specific the measurement model in a way like the below:
library(seminr)
mobi_mm <- constructs(
reflective("Image", multi_items("IMAG", 1:5)),
reflective("Expectation", multi_items("CUEX", 1:3)),
reflective("Quality", multi_items("PERQ", 1:7)),
reflective("Value", multi_items("PERV", 1:2)),
reflective("Satisfaction", multi_items("CUSA", 1:3)),
reflective("Complaints", single_item("CUSCO")),
reflective("Loyalty", multi_items("CUSL", 1:3))
)
The output I am expecting to have my table converted in this format:
mobi_mm <- constructs(
reflective("V7", multi_items(item_numbers = c(9,10,11,12,15)),
...
)
I'd imagine some do.call can be used but not entirely sure how exactly I would do so in this specific example.