运行R CMD检查时,打印检查标记正在触发警告

发布于 2025-02-02 18:02:51 字数 345 浏览 2 评论 0原文

我正在编写一个简单的功能,该功能从用户读取多个文件,然后将其打印到终端(print)文件名中,如果是有效的/无效的,则是或否。我想使用X/✓符号。

但是,由于检查符号不在ASCII中,因此R CMD发出警告。我尝试了几种方法(ChartOraw,Inttoutf8,符号(“ \ 326”),但NON正在使用终端中的简单打印。 例如:

Df <- data.frame(file = myfiles, status = “x”)
Df$status[1]= “✓”
print (Df)

有什么想法吗?谢谢

I‘m writing a simple function that reads multiple files from the user, then it prints into the terminal (print) file name and yes or no next to it, if it was valid/invalid. I would like to use x/✓symbols.

The problem however, since the check symbol is not in ascii, R cmd is throwing a warning. I tried several approaches (charToRaw, intToUtf8, symbol(“\326”) yet non is working with simple print in terminal.
As an example:

Df <- data.frame(file = myfiles, status = “x”)
Df$status[1]= “✓”
print (Df)

Any idea? Thanks

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

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

发布评论

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

评论(1

木槿暧夏七纪年 2025-02-09 18:02:51

cli软件包提供了一种用cli_alert_successcli_alert_danger打印它们的方法。据推测,您对文件是否有效进行了一些更复杂的检查。将其作为布尔而不是明确的字符存储。

Df <- data.frame(file = myfiles, isValid = myValidityCheckFx(myfiles))
purrr::walk2(
    Df$file, Df$isValid, 
    ~if(.y) cli::cli_alert_success(.x) else cli::cli_alert_danger(.x)
)

The cli package offers a way to print these with cli_alert_success and cli_alert_danger. Presumably, you have some more complicated check as to if the file was valid. Store that as a boolean instead of the explicit character.

Df <- data.frame(file = myfiles, isValid = myValidityCheckFx(myfiles))
purrr::walk2(
    Df$file, Df$isValid, 
    ~if(.y) cli::cli_alert_success(.x) else cli::cli_alert_danger(.x)
)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文