r markdown中的桌子

发布于 2025-02-03 20:58:57 字数 645 浏览 3 评论 0 原文

我想在R Markdown中创建一个手动表,我的目标是将最终输出如下:

我尝试了以下代码,但它没有起作用:

Authority   | Responsibility                 | Period
:-----      | :----                          | :-----
 MOIWR      |           Text 1               | 2010
   ^^       |           Text 2               | 2011 
   ^^       |           Text 3               | 2012  
   IWC      |           Text 4               | 2013 
   SGB      |           Text 5               | |

您能帮我弄清楚如何做到这一点!

I would like to create a manual table in R markdown, I am aiming to have the final output as follow:
enter image description here

I tried the following code but it did not work:

Authority   | Responsibility                 | Period
:-----      | :----                          | :-----
 MOIWR      |           Text 1               | 2010
   ^^       |           Text 2               | 2011 
   ^^       |           Text 3               | 2012  
   IWC      |           Text 4               | 2013 
   SGB      |           Text 5               | |

could you please help me to figure out how to do that !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天生の放荡 2025-02-10 20:58:57

Pandoc是R Markdown中使用的转换器,尚未支持带有多个行和/或列的单元格的标记表。一个很好的解决方法是在html中写下表,然后在a

以下过滤器检测到HTML表,并确保可以将其转换为不同的输出格式:

function RawBlock (raw)
  if raw.format:match 'html' and raw.text:match '^%s*%<table' then
    return pandoc.read(raw.text, 'html').blocks
  end
end

使用这样的过滤器:

---
output:
  html_document:
    pandoc_args:
      - '--lua-filter=html-table.lua'
---

``` {=html}
<table>
  <tr>
    <td>column 1</td>
    <td>column 2</td>
  </tr>
  <tr>
    <td colspan="2">column 1 and 2</td>
  </tr>
</table>
```

Pandoc, the converter used in R Markdown, does not yet support Markdown tables with cells spanning multiple rows and/or columns. A good workaround is to write the table in HTML and to parse it in a Lua filter.

The following filter detects HTML tables and makes sure they can be converted to different output formats:

function RawBlock (raw)
  if raw.format:match 'html' and raw.text:match '^%s*%<table' then
    return pandoc.read(raw.text, 'html').blocks
  end
end

Use the filter like this:

---
output:
  html_document:
    pandoc_args:
      - '--lua-filter=html-table.lua'
---

``` {=html}
<table>
  <tr>
    <td>column 1</td>
    <td>column 2</td>
  </tr>
  <tr>
    <td colspan="2">column 1 and 2</td>
  </tr>
</table>
```
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文