[R] incorrect number of dimensions

2014-09-11 Thread Marie-Eve St-Onge
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(10, 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.


[R] How to plot a similar graph

2014-09-18 Thread Marie-Eve St-Onge
Dear all, I would like to draw something similar to the following picture, does 
anyone know a better strategy to start?
http://www.psrd.hawaii.edu/WebImg/Pyx-thermometer.gif
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.