How to obtain Tukey Table in R? The R provides a very confusing function for Tukey distribution.
The function qtukey needs a nonsensical parameter nmeans which forces the size of each treatment group to be the same.
My question is how can we obtain a Tukey upper quantile table(for studentized range distribution) table using qtukey function?(The table is like Tukey Table)
In SAS, it provides a perfect solution of prob('range',.,prob,df,v),should I type qtukey(1-prob,(df+v)/v,df,nrange=v) in R?
But when I type that, I get a wrong number for $q_{\nu,df,\alpha}$? I just do not understand why R provides such a obscure function.
 A: Here is a way to generate QTable into a data frame.
You can change the grid limits according to your needs.
QTable <- expand.grid(alpha=c(0.01,0.05),
                      groups=seq(2,10,1),
                      df=seq(2,120,1))

QTable$QVal=qtukey(1-QTable$alpha,QTable$groups,df=QTable$df)

  head(QTable)
  alpha groups df      QVal
  1  0.01      2  2 13.902105      
  2  0.05      2  2  6.079637
  3  0.01      3  2 19.015496
  4  0.05      3  2  8.330783
  5  0.01      4  2 22.563706
  6  0.05      4  2  9.799011

A: For exaplanatory purpose, I tried to make up a function which provides full Tukey Table, see my comments inside. I still think that the R-help is misleading in this case:
QTable<-function(dfrange=10,nurange=20,alpha=0.05,digs=3){

  ROWS<-dfrange
  COLS<-nurange
  tabl<-matrix(nrow=ROWS,ncol=COLS)
  for(a in 2:COLS){
    tabl[1,a]=a
  }
  for(b in 2:ROWS){
    tabl[b,1]=b
  }

  for(i in 2:ROWS){
    for(j in 2:COLS){
      tabl[i,j]<-qtukey(alpha,j,i,nranges=1,lower.tail=FALSE)
      #R has a wrong description for the parameter 'nmeans',
      #To get a correct result, always set 'nranges'=1, from the description       #of R:
      #i=n-nu;j=nu->n=i+j;nu=j->number of groups nu=j;
      #Each group has n/nu elements, which is (i+j)/j
      #The above interpretation is wrong, the parameter 'nmeans' 
      #should be regarded as number of groups when 'nranges'=1
      tabl[i,j]<-round(tabl[i,j],digs)
    }
  }
  tmp<-as.data.frame(tabl)
  colnames(tmp)<-as.character(tmp[1,])
  tmp<-tmp[-1,]
  rownames(tmp)<-as.character(tmp[,1])
  tmp<-tmp[,-1]
  message("significant level=",alpha)
  message("nu=1:",nurange,", df=1:",dfrange)
  message("Rows are the value sequence of df;Columns are the nu sequence.")
  print(tmp)
}
QTable(dfrange=20,nurange=8,alpha=0.01)

