Reputation: 99
filepath <- paste0("path")
parameters <- list(header=T,row.names=1,sep="\t",check.names=F,stringsAsFactors=F)
input<- read.table(filepath,parameters)
However, I got a error message says:
Error in !header : invalid argument type
It works fine when the parameters are not put in the list like
filepath <- paste0("path")
input <- read.table(filepath,header=T,row.names=1,sep="\t",check.names=F,stringsAsFactors=F)
Since I am importing many data and the parameters are the same,I am wondering how I can pass the parameters in the read.table
function.
Upvotes: 2
Views: 273
Reputation: 28461
Try do.call
. It allows you to provide a list of arguments. Add filepath
to the parameters variable:
do.call(read.table, c(filepath, parameters))
Upvotes: 3