[R] Using %variable% object-column names in function

Uwe Ligges ligges at statistik.uni-dortmund.de
Wed Feb 9 19:32:07 CET 2005


achilleas.psomas at wsl.ch wrote:

> Dear R-help..
> 
> I am rather new in R so i would appreciate your help in my problem..
> I cant seem to be able to write a function that has arguments being  objects and
> column names of these ojbects...
> A simple example code that doesnt work is the following..
> 
> 
> auto_plot <- function (object1,column1,object2,column2) {
> 
> 
> plot(object1$column1,object2$column2)


    plot(object1[[column1]], object2[[column2]])

Uwe Ligges

> }
> 
> 
> I get the message:
> Error in xy.coords(x, y, xlabel, ylabel, log) :
>         x and y lengths differ
> 
> Maybe the solution is simple but i just couldnt find it..
> 
> 
> Thanks a lot for your help..
> 
> Achilleas.
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list