2013-03-20 5 views

答えて

8

私はあなたができるとは思わないがここでは回避策です。内のファイルを読み込む機能、subを使用して、そのラインをきれいにし、ペーストread.tableにそれを渡す前に戻って一緒にすべて:

my.read.table <- function(file, comment.char = "//", ...) { 
    clean.lines <- sub(paste0(comment.char, ".*"), "", readLines(file)) 
    read.table(..., text = paste(clean.lines, collapse = "\n")) 
    } 

テスト:

file <- textConnection("3 4 //a 
         1 2") 
my.read.table(file) 
# V1 V2 
# 1 3 4 
# 2 1 2 
+0

これは本当によさそうだ、ありがとう! –

+0

+!とても素敵な答え –

関連する問題