Dear all, I'm trying the following experiment simulation, but I'm receiving this error: > probs()Error in x[j, 4] : incorrect number of dimensions however, the simulation works fine outside the function statement{}. What am I doing wrong? # Create some fake data and call the function: df <- data.frame(y1 = rpois(5, 9),y2 = rpois(5, 7), y3 = rpois(5, 8), n = rpois(5, 100)) probs = function(x='df', j=5, export=1){ p=gtools::rdirichlet(100000, x[j,4] * c(x[j,1],x[j,2],x[j,3], 1-x[j,1]-x[j,2]-x[j,3])/100+1 )if(export==1){ mean(p[,1] > p[,3])} else { return(p)} }
Eve [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.