r - 在 R 中获取函数时在控制台中静音或抑制文本
问题描述
我正在使用reticulate
从 python 文件中获取函数reticulate::source_python()
。但是,当我第一次在会话中获取它时,这会在 RStudio 控制台中以红色打印文本(警告);我想沉默或压制它。我尝试了几种方法,但都没有奏效:
# Attempt 1
suppressWarnings("My source_python(path_to_function)")
# Attempt 2
suppressMessages("My source_python(path_to_function)")
# Attempt 3
capture.output("My source_python(path_to_function)")
# Attempt 4
invisible("My source_python(path_to_function)")
# Attempt 5
invisible(capture.output("My source_python(path_to_function)"))
# Attempt 6
zz <- file("test.txt", open = "wt")
sink(zz ,type = "output")
sink(zz, type = "message")
print("using print")
cat("using cat\n")
message("using message")
warning("using warning")
"My source_python(path_to_function)"
#and to close connections
sink()
sink()
file.show("test.txt")
有没有其他方法可以尝试。提前致谢。
解决方案
推荐阅读
- xamarin - 虽然在android中拒绝相机权限,但它不会再次询问
- unity3d - 穿过物体的光投射
- c++ - 为数组元素赋值后程序崩溃
- java - 我的图像没有被压缩 - 我该怎么办?
- docker - 我们可以从单个 docker 日志驱动程序将日志发送到多个位置吗
- android - Android Studio:使用 Firebase 显示当前用户数据的程序
- jquery - 页面加载时自动触发锚标记
- node.js - React/Vue(或任何其他类似框架)MPA 实现
- ruby-on-rails - 迁移中的 Rails 活动记录序列化
- javascript - 如何在控制台日志中查看所选选项与其他选项的组合?