Haven’t looked at this in detail, but I don’t really understand the need for RCall here? It looks to me like everything up to and including the loop can be replaced by:
using Distributions
dataMatrix = rand(Normal(), 40, 10)
dataMatrix .+= (repeat([0, 3], inner = 5) * rand(Bernoulli(), 40)')'