[R] help in function in R akin to macro in SAS

Thomas Lumley tlumley at u.washington.edu
Tue Apr 6 18:57:36 CEST 2010


On Tue, 6 Apr 2010, Stuart Luppescu wrote:

> On Tue, 2010-04-06 at 09:33 -0700, Changbin Du wrote:
>> #plot function
>> plotxyf<-function (data) {
>>
>> plot(data, type="mapping", labels=final$target, col=final$outcome+1,,
>> main="Supervised: Mapping plot for data")
>
> Change this to: main=paste("Supervised: Mapping plot for", data)

Umm, no.  That will put the entire data set into the title

plotxyf<-function(data){

     data.name<-deparse(substitute(data))
    plot(data, type="mapping", labels=final$target, col=final$outcome+1,
       main=paste("Supervised: Mapping plot for", data.name)

}

might work

    -thomas

>>
>>                                       }
>>
>>
>> #use the plotxyf function.
>> plotxyf(final.xyf)
>
> BTW, I think it's better not to use "data" as a function parameter,
> since it has reserved use in the language.
>
> -- 
> Stuart Luppescu <slu at ccsr.uchicago.edu>
> University of Chicago
>
> ______________________________________________
> 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.
>

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle



More information about the R-help mailing list