修复多个警告“未知列" [英] Fixing a multiple warning "unknown column"

查看:16
本文介绍了修复多个警告“未知列"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于所有类型的命令(例如,在包上安装更新的 str(x)),我都有一个未知列"的持续多次警告,并且不确定如何调试或修复它.

警告未知列"显然与我重命名的 tbl_df 中的一个变量有关,但警告出现在各种看似与 tbl_df 无关的命令中(例如,在包上安装更新,str(x)其中 x 只是一个字符向量).

解决方案

这是 RStudio 中的诊断工具(显示代码中的警告和可能错误的工具)的问题.commit 在 RStudio v1.1.103 或更高版本中由 @kevin-ushey.该修复是部分的,因为警告仍然出现(尽管频率较低).此问题在 https://github.com/rstudio/rstudio/issues/7372 并在 RStudio v1.4 拉取请求上修复.>

更新到最新的 RStudio 版本以解决此问题.或者,有多种解决方法可用,选择您喜欢的解决方案:

  • 在 Preferences/Code/Diagnostics 中禁用所有文件的代码诊断

  • 禁用特定文件的所有诊断:

    在打开的文件开头添加:

     # !diagnostics off

    然后保存文件,警告应该停止出现.

  • 禁用导致警告的变量的诊断

    在打开的文件开头添加:

     # !diagnostics suppress=<逗号分隔的变量列表>

    然后保存文件,警告应该停止出现.

出现警告是因为 RStudio 中的诊断工具解析源代码以检测错误,当它执行诊断检查时,它会访问您的 tibble 中未初始化的列,从而给出我们看到的警告.警告不会出现,因为您运行了无关的东西,它们会在执行 RStudio 诊断时出现(当文件被保存,然后修改,当你运行某些东西时......).

I have a persistent multiple warning of "unknown column" for all types of commands (e.g., str(x) to installing updates on packages), and not sure how to debug this or fix it.

The warning "unknown column" is clearly related to a variable in a tbl_df that I renamed, but the warning comes up in all kinds of commands seemingly unrelated to the tbl_df (e.g., installing updates on a package, str(x) where x is simply a character vector).

解决方案

This is an issue with the Diagnostics tool in RStudio (the tool that shows warnings and possible mistakes in your code). It was partially fixed at this commit in RStudio v1.1.103 or later by @kevin-ushey. That fix was partial, because the warnings still appeared (albeit with less frequency). This issue was reported with a reproducible example at https://github.com/rstudio/rstudio/issues/7372 and it was fixed on RStudio v1.4 pull request.

Update to the latest RStudio release to fix this issue. Alternatively, there are several workarounds available, choose the solution you prefer:

  • Disable the code diagnostics for all files in Preferences/Code/Diagnostics

  • Disable all diagnostics for a specific file:

    Add at the beginning of the opened file(s):

     # !diagnostics off
    

    Then save the files and the warnings should stop appearing.

  • Disable the diagnostics for the variables that cause the warning

    Add at the beginning of the opened file(s):

     # !diagnostics suppress=<comma-separated list of variables>
    

    Then save the files and the warnings should stop appearing.

The warnings appear because the diagnostics tool in RStudio parses the source code to detect errors and when it performs the diagnostic checks it accesses columns in your tibble that are not initialized, giving the Warning we see. The warnings do not appear because you run unrelated things, they appear when the RStudio diagnostics are executed (when a file is saved, then modified, when you run something...).

这篇关于修复多个警告“未知列"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆