zhijie zhang
2007-Sep-23 07:53 UTC
[R] return(x=x,y=y,prob=prob) hasn't been used in R now?
Dear friends, Now, when i use the argument return(x=x,y=y,prob=prob) , R displays the waring message: Warning message: The return value for multiple variables wasn't used in: return(x = x, y gy, prob = prob) I used the methods of "help.search("return")" and "?return" to get some help, but didn't find info on it. Anybody knows how it should be used correctly? #EXAMPLES a<-function(x,y,z) { gx<-seq(1,10,length.out=20) gy<-gx prob<-matrix(20,20) for (i in 1:20) { for (j in 1:20) { prob<-0.1 } } return(x=gx,y=gy,prob=prob) } a(1,1,1) # the warning message will display Thanks. -- With Kind Regards, oooO::::::::: (..)::::::::: :\.(:::Oooo:: ::\_)::(..):: :::::::)./::: ::::::(_/:::: ::::::::::::: [***********************************************************************] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 Dept. of Epidemiology,School of Public Health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 Email:epistat@gmail.com Website: www.statABC.com [***********************************************************************] oooO::::::::: (..)::::::::: :\.(:::Oooo:: ::\_)::(..):: :::::::)./::: ::::::(_/:::: ::::::::::::: [[alternative HTML version deleted]]
Peter Dalgaard
2007-Sep-23 08:36 UTC
[R] return(x=x,y=y,prob=prob) hasn't been used in R now?
zhijie zhang wrote:> Dear friends, > Now, when i use the argument return(x=x,y=y,prob=prob) , R displays the > waring message: > Warning message: > The return value for multiple variables wasn't used in: return(x = x, y > gy, prob = prob) > I used the methods of "help.search("return")" and "?return" to get some > help, but didn't find info on it. > Anybody knows how it should be used correctly? >Return(value) takes only one argument. To return a list, return(list(x=x,y=y,prob=prob)) I bet the author of help(return) thought that this was implied clearly enough.> #EXAMPLES > a<-function(x,y,z) > { > gx<-seq(1,10,length.out=20) > gy<-gx > prob<-matrix(20,20) > for (i in 1:20) > { > for (j in 1:20) > { > prob<-0.1 > } > } > return(x=gx,y=gy,prob=prob) > } > > a(1,1,1) # the warning message will display > Thanks. > >-- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907