r - 在与子集数据表连接的情况下,为什么列优先于数据表中同名的对象
问题描述
test <- function() {
operator_descriptions <- data.table(operator = "/", description = "/")
operator_conditions <- data.table(operator = "/", condition = "Quotient non zero")
condition <- c(TRUE)
operator_conditions[operator_descriptions[condition], on = c("operator")]
}
test()
Output
Error: When i is a data.table (or character vector), the columns to join by must be specified either using 'on=' argument (see ?data.table) or by keying x (i.e. sorted, and, marked as sorted, see ?setkey). Keyed joins might have further speed benefits on very large data due to x being sorted in RAM.
尽管 condition 在 的范围内operator_descriptions
,但condition
column ofoperator_conditions
似乎优先condition
于前面语句中定义的对象。
这种行为需要对名称等保持谨慎。虽然在正常情况下,这很好,因为我们打算主要使用列名。但在这样的情况下,我不确定这是否是故意的。
解决方案
推荐阅读
- python - 对象没有属性'split()' Python
- c# - 如果我使用其中的许多而不是一个,EFCore DbContext 会更快吗?为什么?
- git - How will a branch off a branch look like when I do git branch -a?
- html - How do I make an li change colour when active?
- javascript - React Native 中的像素颜色
- python-3.x - How to sum data and join columns using Pandas
- javascript - RequestAnimationFrame,参数与变量
- php - 在 PHP 中将新文件添加到具有外键错误的数据库
- ios - Can't make Apple Sign In work with Xamarin.Essentials
- vue.js - Vue: lazy loading from library (Bootstrap-Vue) inside a component