2016-10-23 8 views
0

私は、.txtファイルで使用される区切り文字を識別するアルゴリズムを持っています。私はcat()を使って見つかったセパレータを出力したいと思います。私は%ssprintf()を使用しています。sprintfを使って文字列 " t"を表示するには?

current.sep = "\t" 

cat(sprintf("Found separator : %s. \n", current.sep)) 
## Found separator : . 

cat(sprintf("Found separator : %s. \n", "current.sep")) 
## Found separator : current.sep. 

## I want: 
## Found separator : \t. 
+1

それは...それを示すのですか? '## Separator:.'(コメントはスペースは削除されていますが、w/e)には' \ t'がありますか? –

答えて

1
print_separator <- function(separator) { 

    expr <- deparse(paste0("Found separator : ", separator, ".")) 
    cat(substr(expr, 2, nchar(expr) - 1)) 

} 

print_separator(current.sep) 
## Found separator : \t. 
関連する問題