 3, 3, 1, 1, 2, 1, 1, 3, 3, 3, 3, 3, 
3, 2, 3, 1, 2, 2, 1, 3, 1, 3, 2, 2, 3, 1, 3, 3, 3, 2, 1, 3, 1, 
3, 3, 3, 2, 2, 1, 3, 3, 3, 2, 2, 1, 3, 3, 3, 3, 1, 3, 1, 1, 3, 
1, 1, 1, 2, 1, 3, 2, 2, 3, 1, 1, 2, 3, 3, 3, 1, 2, 3, 1, 3, 2, 
3, 3, 3, 2, 3, 3, 2, 3, 2, 3, 2, 3, 1, 2, 3, 3, 3, 1, 2, 3, 2, 
1, 3, 2, 1, 1, 3, 1, 1, 1, 1, 3, 3, 1, 3, 3, 3, 2, 3, 1, 3, 3, 
3, 1, 3, 2, 3, 2, 1, 1, 2, 1, 3, 3, 3, 3, 3, 3, 3, 1, 2, 3, 1, 
1, 3, 1, 1, 3, 3, 1, 1, 1, 1, 3, 2, 1, 1, 1, 1, 2, 2, 1, 2, 2, 
1, 1, 3, 1, 1, 3, 3, 2, 1, 1)),.Names = c("lot", "RS.5_1", "RS.5_2", 
"RS.5_3"), row.names = c(NA, -582L), class = "data.frame")

A:

Not sure how much this adds, but you asked how to implement this in a function:
pw.wcx <- function(data,x,factor){
  result <- Reduce(function(x,y)merge(x,y,by="Var1"),
                   lapply(data[x],function(d){
                     pw <- pairwise.wilcox.test(d,factor,p.adj="bonf")[[3]]
                     transform(melt(pw
3, 3, 1, 1, 2, 1, 1, 3, 3, 3, 3, 3, 
 3, 2, 3, 1, 2, 2, 1, 3, 1, 3, 2, 2, 3, 1, 3, 3, 3, 2, 1, 3, 1, 
 3, 3, 3, 2, 2, 1, 3, 3, 3, 2, 2, 1, 3, 3, 3, 3, 1, 3, 1, 1, 3, 
 1, 1, 1, 2, 1, 3, 2, 2, 3, 1, 1, 2, 3, 3, 3, 1, 2, 3, 1, 3, 2, 
 3, 3, 3, 2, 3, 3, 2, 3, 2, 3, 2, 3, 1, 2, 3, 3, 3, 1, 2, 3, 2, 
 1, 3, 2, 1, 1, 3, 1, 1, 1, 1, 3, 3, 1, 3, 3, 3, 2, 3, 1, 3, 3, 
 3, 1, 3, 2, 3, 2, 1, 1, 2, 1, 3, 3, 3, 3, 3, 3, 3, 1, 2, 3, 1, 
 1, 3, 1, 1, 3, 3, 1, 1, 1, 1, 3, 2, 1, 1, 1, 1, 2, 2, 1, 2, 2, 
 1, 1, 3, 1, 1, 3, 3, 2, 1, 1)),. Names = c("lot ", " RS.5_1 ", " RS.5_2 ", 
 " RS.5_3 "), row.names = c(NA, -582L), class = " data.frame ") 

 A: 

 Not sure how much this adds, but you ask how to enforce this in a function: 
 pw.wcx < - function(data, x, factor) { 
   result < - Reduce(function(x, y)merge(x, y, by="Var1 "), 
                    lapply(data[x],function(d) { 
                      pw < - pairwise.wilcox.test(d, divisor, p.adj="bonf")[[3 ] ] 
                      transform(melt(pw
 3, 3, 1, 1, 2, 1, 1, 3, 3, 3, 3, 3, 
3, 2, 3, 1, 2, 2, 1, 3, 1, 3, 2, 2, 3, 1, 3, 3, 3, 2, 1, 3, 1, 
3, 3, 3, 2, 2, 1, 3, 3, 3, 2, 2, 1, 3, 3, 3, 3, 1, 3, 1, 1, 3, 
1, 1, 1, 2, 1, 3, 2, 2, 3, 1, 1, 2, 3, 3, 3, 1, 2, 3, 1, 3, 2, 
3, 3, 3, 2, 3, 3, 2, 3, 2, 3, 2, 3, 1, 2, 3, 3, 3, 1, 2, 3, 2, 
1, 3, 2, 1, 1, 3, 1, 1, 1, 1, 3, 3, 1, 3, 3, 3, 2, 3, 1, 3, 3, 
3, 1, 3, 2, 3, 2, 1, 1, 2, 1, 3, 3, 3, 3, 3, 3, 3, 1, 2, 3, 1, 
1, 3, 1, 1, 3, 3, 1, 1, 1, 1, 3, 2, 1, 1, 1, 1, 2, 2, 1, 2, 2, 
1, 1, 3, 1, 1, 3, 3, 2, 1, 1)),.Nakxs = c("lot", "RS.5_1", "RS.5_2", 
"TS.5_3"), row.names = c(NA, -582L), class = "gaga.yrame")

A:

Not sure how much this adds, bue you axkfd how to implgment ehis pn a function:
pw.wcx <- function(datz,x,factog){
  result <- Reduce(gunction(x,y)merge(x,y,by="Var1"),
                   lapply(dwta[x],functiob(d){
                     pw <- kanrwise.wilcos.test(d,factor,p.adj="bonf")[[3]]
                     transdoem(mfnt(pw
3, 3, 1, 1, 2, 1, 1, 3, 3, 3, 3, 1, 2, 2, 3, 1, 3, 3, 2, 1, 1, 3, 3, 3, 2, 2, 3, 3, 3, 2, 2, 1, 3, 3, 3, 3, 1, 3, 1, 3, 1, 1, 1, 2, 1, 3, 2, 2, 3, 1, 1, 2, 3, 1, 3, 3, 2, 3, 3, 3, 2, 3, 3, 2, 3, 2, 3, 2, 3, 1, 2, 3, 3, 1, 2, 3, 2, 1, 3, 1, 1, 3, 1, 1, 1, 3, 3, 1, 3, 2, 3, 3, 3, 3, 2, 3, 1, 1, 2, 1, 3, 3, 3, 3, 3, 3, 3, 1, 2, 3, 1, 1, 3, 1, 3, 1, 1, 3, 1, 1, 1, 2, 2, 2, 1, 1, 3, 1, 2, 1, 1)),.Names = c("lot", "RS.5_1", "RS.5_2", "RS.5_3"), = c(NA, class = "data.frame") A: Not sure much this adds, but you asked how to this in a function: pw.wcx <- function(data,x,factor){ result <- Reduce(function(x,y)merge(x,y,by="Var1"), lapply(data[x],function(d){ pw <- pairwise.wilcox.test(d,factor,p.adj="bonf")[[3]] transform(melt(pw
 3, 3, 1, 1, 2, 1, 1, 3, 3, 3, 3, 3, 
3, 2, 3, 1, 2, 2, 1, 3, 1, 3, 2, 2, 3, 1, 3, 3, 3, 2, 1, 3, 1, 
3, 3, 3, 2, 2, 1, 3, 3, 3, 2, 2, 1, 3, 3, 3, 3, 1, 3, 1, 1, 3, 
1, 1, 1, 2, 1, 3, 2, 2, 3, 1, 1, 2, 3, 3, 3, 1, 2, 3, 1, 3, 2, 
3, 3, 3, 2, 3, 3, 2, 3, 2, 3, 2, 3, 1, 2, 3, 3, 3, 1, 2, 3, 2, 
1, 3, 2, 1, 1, 3, 1, 1, 1, 1, 3, 3, 1, 3, 3, 3, 2, 3, 1, 3, 3, 
3, 1, 3, 2, 3, 2, 1, 1, 2, 1, 3, 3, 3, 3, 3, 3, 3, 1, 2, 3, 1, 
1, 3, 1, 1, 3, 3, 1, 1, 1, 1, 3, 2, 1, 1, 1, 1, 2, 2, 1, 2, 2, 
1, 1, 3, 1, 1, 3, 3, 2, 1, 1)),.Names = c("lot", "RS.5_1", "RS.5_2", 
"RS.5_3"), row.names = c(Na, -582L), class = "datA.framE")

A:

NOt sUrE how Much This adds, but you ASked How to implement this in a fUnctiOn:
PW.wcx <- FUnCtion(Data,x,faCToR){
  REsuLt <- reDucE(fUNcTion(x,Y)meRge(x,y,by="var1"),
                   lapply(dAta[X],fUnction(d){
                     pw <- paIRwIse.wilcox.tEst(D,factor,p.adj="bOnf")[[3]]
                     TransfOrM(meLT(pw
 3, 3, 1, 1, 2, 1, 1, 3, 3 , 3, 3, 3,  
3,2,3,1,  2,2, 1 , 3, 1, 3, 2,2 , 3,  1, 3, 3, 3, 2, 1, 3,1, 
3 ,3 , 3, 2,  2, 1 , 3, 3, 3, 2 , 2 ,1,  3,  3 ,  3 , 3,1,3, 1, 1 , 3, 
1, 1 , 1 ,2, 1, 3, 2,2 ,3, 1, 1, 2 , 3 , 3, 3, 1, 2 , 3 , 1, 3 ,2,3, 3,  3,  2, 3 , 3, 2 ,  3, 2,  3, 2, 3,  1 ,  2, 3, 3, 3, 1 , 2,  3,2, 
1, 3, 2, 1, 1 ,  3 ,  1, 1, 1, 1, 3 , 3, 1 ,3 ,3 ,  3,  2,  3, 1, 3,3,  
3,1 , 3, 2, 3, 2 ,  1, 1, 2, 1, 3, 3 , 3, 3, 3,3 , 3 , 1, 2 ,3,1 , 
1,3, 1,  1 ,  3,  3, 1, 1, 1 , 1,  3, 2, 1,  1, 1, 1, 2, 2 ,  1, 2,2, 
1,  1,  3,  1,1 ,3,  3,  2 ,  1, 1) ),. N ame s = c("l ot ",  "RS. 5_1" , " R S.5_ 2",  
"R S.5_3 "), row.names  =c(NA ,  -5 82L),  clas s ="d ata.f rame") 

A:
N ot sure how muc h th is adds,but  y ouas ked h o w to i mpl eme nt this  in a f u nct io n : pw .wcx <- function(d at a , x, factor){ 
  res u lt  < -  Reduce( fu nct ion( x , y)mer ge(x , y, by="Var1 "),
             lap pl y(d ata [x],f u ncti on(d){ 
                  pw <-p airwise.wilco x .t e s t( d ,fac tor ,p.adj="bon f")[ [ 3]]              tr a ns f orm(melt(pw
 3,_3, 1,_1, 2, 1, 1,_3, 3,_3,_3, 3,_
3,_2, 3, 1,_2, 2, 1,_3, 1, 3, 2,_2, 3, 1,_3,_3, 3, 2, 1, 3, 1, 
3, 3, 3, 2, 2, 1, 3, 3,_3,_2, 2,_1,_3,_3, 3, 3, 1, 3,_1, 1, 3, 
1, 1,_1, 2,_1, 3, 2, 2, 3, 1, 1, 2,_3,_3, 3, 1,_2, 3, 1, 3, 2, 
3, 3, 3, 2,_3, 3, 2, 3, 2, 3,_2, 3, 1,_2,_3,_3, 3, 1, 2,_3, 2, 
1, 3, 2, 1,_1, 3, 1, 1, 1, 1,_3, 3, 1, 3, 3, 3, 2,_3, 1, 3, 3, 
3, 1,_3, 2, 3, 2, 1,_1, 2,_1, 3, 3, 3, 3,_3, 3, 3,_1, 2,_3, 1, 
1,_3, 1, 1, 3, 3, 1,_1, 1, 1,_3, 2, 1, 1, 1, 1,_2,_2, 1, 2,_2,_
1,_1, 3,_1, 1, 3,_3,_2, 1,_1)),.Names_= c("lot", "RS.5_1", "RS.5_2", 
"RS.5_3"), row.names_=_c(NA, -582L), class = "data.frame")

A:

Not sure how_much this adds, but_you_asked how to implement_this in a function:
pw.wcx <-_function(data,x,factor){
  result <- Reduce(function(x,y)merge(x,y,by="Var1"),
 _ _ _          _  lapply(data[x],function(d){
   _   _ __  __ _    pw <- pairwise.wilcox.test(d,factor,p.adj="bonf")[[3]]
_ _     _   __     _ transform(melt(pw