Hello dear R-help I would like to use some short and simple names multiple times inside one script without collisions. I need to wrap the variables inside some object. I know I can use class function or environment. For example as follows:
exmp1<-function(){ ######## # knowns pa=0.35 pb=0.35 pc=0.30 pad=0.015 pbd=0.010 pcd=0.020 ######## ######## # unknowns pd=pa*pad+pb*pbd+pc*pcd pdc=pc*pcd/pd pda=pa*pad/pd pba=pb*pbd/pd ######## y<-c(pad=pad,pbd=pbd,pcd=pcd,pd=pd,pdc=pdc,pda=pda,pba=pba) # this line I would like to automate so I don't have to write it every time return(y) } output<-exmp1() Is it somehow possible to print 'Unknows' and 'Knowns' from exmp1 function without the need of explicitly write the 'y' line which puts all variables inside list? For example with an imaginary function 'fprint' which takes exmp1 as the input: fprint(exmp1). ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.