在markdown中循环打印r个注释

时间:2016-05-02 12:26:59

标签: r comments r-markdown

我正在使用for循环生成模型结果并在r markdown中打印它们。为了保持整洁,在打印模型结果之前打印注释会很不错。

有没有办法在R中打印标签后面的注释文本?

e.g。

constructor(platform: Platform, public http: Http) {
    this.platform = platform;
    this.headers = new Headers();
    this.headers.append('Content-Type', 'application/x-www-form-urlencoded');
}



send(subject, body)
{
    var body = "subject=" + subject + "&body=" + body;

    let result = this.http.post('http://172.16.2.115:3004/message',
        body, 
        {
            headers: this.headers
        });


    console.log(body);
    console.log(this._apiUrl);

    return result;         
}

VS

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

1 个答案:

答案 0 :(得分:0)

在我看来,无需尝试打印评论。您可以在循环中使用cat("this is the number", i, "\n")。例如:

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,往往是首选,因为我们可以使用suppressMessages轻松摆脱它们,或者更好,message=FALSE在knitr / rmarkdown {{3 }}