cbind 中的单引号用于将数据附加到 R 中的数据框

single quote in cbind for appending data to data frame in R

我正在尝试理解以下代码行中的语法。 cbind 函数中的单引号在这里做什么?如果可能,请举例说明。有关完整的代码示例,请访问此 site.

Type:

'after' : logical
'check' : vector

if (after) cbind(data, ' ' = check) else cbind(' ' = check, data)

这只是在结果 data.frame 中为附加列指定一个空(看起来)名称的便捷方法。

比较:

> data <- data.frame(a=1:3, b=4:6)
> cbind(data, 1:3)
  a b 1:3
1 1 4   1
2 2 5   2
3 3 6   3
> cbind(data, ' '=1:3)
  a b  
1 1 4 1
2 2 5 2
3 3 6 3

## And just to see for yourself that the column name is not really empty...
> names(cbind(data, ' '=1:3))
[1] "a" "b" " "