如何使用R中的’gt’库通过source运行代码?

huangapple go评论74阅读模式
英文:

How to run code using the 'gt' library in R with source?

问题

我是一个使用R的新手,正在尝试使用"gt"库。每当我运行甚至是简单的测试代码使用"source"时,我无法让表格显示出来。然而,当我突出显示我的代码并使用"run"时,表格就会完美显示出来。肯定是我在这里漏掉了一些简单的东西,所以任何反馈都将不胜感激。

在安装所需的库之后,我运行以下简单代码也遇到了相同的问题。

library(gt)
library(palmerpenguins)

penguins %>% gt()
英文:

I am a novice at using R and am trying to utilize the "gt" library. Whenever, I run even simple test code with 'source', I cannot get the table to appear. However, when I highlight my code and use 'run' the table appears perfectly. Surely, I'm missing something simple here so any feedback will be greatly appreciated.

I have the same issue running the following simple code, after installing the needed libraries.

library(gt)
library(palmerpenguins)

penguins %>% gt()

答案1

得分: 0

你可以尝试这样做 - 将表格保存为一个对象,然后打印该对象:library(gt) library(palmerpenguins) my_table <- penguins %>% gt() print(my_table)

英文:

You can try this- Save the table as an object and then print the object:

library(gt)

library(palmerpenguins)

my_table &lt;- penguins %&gt;% gt()
print(my_table)

huangapple
  • 本文由 发表于 2023年6月5日 12:19:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76403481.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定