【问题标题】:How to generate conditional words in the text? (Inline code)如何在文本中生成条件词? (内联代码)
【发布时间】:2018-10-27 06:27:05
【问题描述】:

我想在我的 R Markdown 文档中添加一些条件词。根据表格中某些计算的结果,不同的单词应该出现在普通文本中。请看下面我的例子:

表(一个块):

testtabell <- matrix(c(32, 33, 45, 67, 21, 56, 76, 33, 22), ncol=3,byrow = TRUE)
colnames(testtabell) <- c("1990", "1991", "1992")
rownames(testtabell) <- c("Region1", "Region2", "Region3")
testtabell <- as.table(testtabell)
testtabell

这应该在内联代码中,并在RMD中的常规文本流中生成不同的单词选项:

`r if testtabell[2,2]-[2,1] < testtabell[3,2]-testtabell[3,1] then type "under" or else "above"`

【问题讨论】:

    标签: r-markdown


    【解决方案1】:

    虽然这个问题很古老,但也许有人可以使用这个解决方案。

    您可以使用以下内联代码:

    `r ifelse(testtabell[2,2]-testtabell[2,1] < testtabell[3,2]-testtabell[3,1],"under","above")`
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多