在没有其他文本的情况下将链接添加到GT表元素
我想将链接添加到我的GT表单元格中,如下所示:
raw_dat <- mtcars[1:15, ] %>% rownames_to_column(var = "id") %>% select(id, mpg)
tibble(
name = raw_dat$id,
link = paste(raw_dat$mpg, "And <a href = 'https://www.cars.com//'>here</a>")) %>%
mutate(link = map(link, gt::html)) %>%
gt
我如何使链接落在raw_dat $ mpg
上,并且之后没有任何其他文本。因此,所需的输出是单击raw_dat $ mpg
单元格,您可以将其带到cars.com。
I want to add links to my gt table cells as shown:
raw_dat <- mtcars[1:15, ] %>% rownames_to_column(var = "id") %>% select(id, mpg)
tibble(
name = raw_dat$id,
link = paste(raw_dat$mpg, "And <a href = 'https://www.cars.com//'>here</a>")) %>%
mutate(link = map(link, gt::html)) %>%
gt
Results:
How can I make the link fall on the raw_dat$mpg
and not have any additional text after it. So the desired output is by clicking on the raw_dat$mpg
cell, you can be taken to cars.com.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用以下代码:
输出:
You can use the following code:
Output:
也许您可以使用
sprintf
构造字符串(显然未测试)。Perhaps you can construct a string using
sprintf
(not tested, obviously).将两个现有解决方案融合在一起。这是一个笔直的
tidyverse
方法:
..... .....
Taking together both existing solution. Here is a straight
tidyverse
approach:.....
.....