Possible Duplicate:
How to pass a function and its arguments through a wrapper function in R? Similar to *args and *kwargs in python
I am trying to write a function using an existing function and be able to pass on the arguments to the existing function without defining each argument in the new function. It is difficult to express this in words. So here is an example: I am writing a function using read.table so that the filename that has to be read is defined passed on using the function I am writing (basically I don't want to change the working directory). Following is the example:
MyFilePath <- "/Users/John/Work/"
read.table.path <- function(file, path){
x <- paste(path, file, sep="/")
return(read.table(x))
}
So to read a file called "table.txt" in that folder:
table <- read.table.path(file="table.txt", path=MyFilePath)
However, how can I use this function (read.table.path
) such that I can pass arguments to read.table
, for example if I want to say header=TRUE
, fill=TRUE
, etc.