2017-02-22 10 views
1

に結果を示すが.txt形式でファイルを保存「ALSO AND」コンソール(Rstudio)cat(...)を示して?ここで同時に出力し、それが両方に可能である場合、私は思ったんだけどR

は私のRコードです:

SOS = 33 
    df = 12 

    cat("\n","-------------", "\n" ,"SOS "," df","\n", "-------------","\n", 
     SOS," ",df,"\n", "-------------", file = "Output.txt") 
+0

'double.cat =関数(...、ファイル){do.call(猫、リスト(...)); – MichaelChirico

+0

私は 'sink'を使ってコンソール出力をファイルに出力します... – drmariod

答えて

1
SOS = 33 
df = 12 

#prepare your output 
x = paste("\n","-------------", "\n" ,"SOS "," df","\n", "-------------","\n", 
            SOS," ",df,"\n", "-------------", sep = "") 

#display in console 
cat(x) 
#------------- 
#SOS df 
#------------- 
#33 12 
#------------- 

#Write to a txt file 
cat(x, file = "output.txt") 
関連する問題