[R] Creating Hmisc labels inside a function

Frank E Harrell Jr f.harrell at vanderbilt.edu
Wed Sep 12 14:37:47 CEST 2007


Steve Powell wrote:
> hello list members,
> I am wanting to write a label using the Hmisc package, but inside a
> function. Normally I can do:
> 
> library(Hmisc)
> M=2
> label(M)="lab"
> 
> #But inside a function the "=" does not work:
> Test=function(obj,labe)
> {
> label(obj)=labe

at this point add the line:

obj

> }

The returned object will have what you need.  -Frank

> 
> Test(M,"new label")
> 
> I usually use the "assign" function to make assignments inside functions,
> but assign will not work with attributes, labels etc.
> Any ideas?
> Thanks in advance
> 
> Steve Powell
> 
>  
> proMENTE social research 
> research | evaluation | training & consulting 
> Kranjčevićeva 35, 71000 Sarajevo 
> mobile: +387 61 215 997 | office: +387 33 556 865 | fax: +387 33 556 866
> skype: stevepowell99 
> www.promente.org  |  www.mojakarijera.com  |  www.psih.org  
> 
> 
> Checked by AVG Free Edition. 
> 
> 17:43
> 
> ______________________________________________
> R-help at 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.
> 


-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University



More information about the R-help mailing list