[R] passing columns of tables as a variable to functions

Sacha Viquerat sacha.vsop at googlemail.com
Tue Mar 16 15:21:24 CET 2010

hello! ive come across the following problem:
im writing a function to ease the production of maps. as my tables have 
headers, id like to include an option in my function header to pass 
these columns to use them inside the evaluation block. the function 
looks as follows:

# maptable #the name of the table containing coordinates and columns for 
measured values
# value: which column of my table to use (e.g. Alt, slope, us, etc...
# labels(maptable)
# [1] "pos.e" "pos.n" "Alt" "slope" "us" "uus" "lc"

make.map<-function (maptable,value)
pos.e<-maptable$pos.e #calling the column directly works
pos.n<-maptable$pos.n #calling the column directly works
key<-maptable$value #this doesnt work. output: NULL
... rest of function, irrelevant to my question

for example, i call the function by:


and my interp from akima package denies work, since key is NULL


have i just missed something? ive browsed the help pages and the 
archive, looked into crawleys R book but didnt find any solution, though 
im pretty sure this should be achievable!

More information about the R-help mailing list