2016-05-02 11 views
0

私はモデルの結果を生成してrマークダウンで印刷するためにforループを使用しています。それをきれいに保つために、モデル結果を印刷する前にコメントを印刷するのが良いでしょう。マークダウンのループでrのコメントを印刷

Rのハッシュタグの背後にコメント付きのテキストを印刷する方法はありますか?

#this is the number 
print(1) 
#this is the number 
print(2) 
#this is the number 
print(3) 
#this is the number 
print(4) 
+0

これは役に立ちましたか?http://stackoverflow.com/questions/17178831/generate-markdown-comments-within-for-loop –

答えて

0

私の意見でコメントを印刷しようとする必要はありません対

for(i in c(1:10)){ 
#this is the number 
print(i)} 

。ループ内でcat("this is the number", i, "\n")を使用することができます。例えば:私たちは簡単にknitr/rmarkdown chunkssuppressMessagesまたは、より良い、message=FALSEでそれらを取り除くことができますよう

for (i in 1:5) 
    cat("this is number", i, "\n") 

this is number 1 
this is number 2 
this is number 3 
this is number 4 
this is number 5 

message代わりcatのは、好まれる傾向にあります。

+0

私が必要としていたものです。ありがとうございました。 – lueromat

+0

あなたはそれを解決済みのようにマークすることができます –