The groups attribute of an ldamat or balanced object can be accessed or modified with the groups function:
Example 3.14: cows data we read in earlier (using read.balanced) does not have a groups attribute. Of the 27 time series, however, the first 4 represent a control group, the next 4 represent cows with an iron supplement, the next 9 represent cows with an infection, and the remaining 10 represent cows with the supplement and an infection. We would like to represent this in the groups attribute:Objects may have only one groups attribute. To represent more complicated grouping structures (such as a two way classification), you must supply factor objects separately from the ldamat or balanced object.
![]()
Note that the groups function ensures that the groups attribute is made into a factor.