cbind中的单引号,用于将数据追加到R中的数据帧
我试图理解下面代码行中的语法。cbind函数中的单引号在这里做什么?如果可能,请举例说明。有关完整的代码示例,请访问此cbind中的单引号,用于将数据追加到R中的数据帧,r,dataframe,R,Dataframe,我试图理解下面代码行中的语法。cbind函数中的单引号在这里做什么?如果可能,请举例说明。有关完整的代码示例,请访问此 这只是一种简便的方法,可以在结果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
这只是一种简便的方法,可以在结果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" " "
数据cbind(数据,1:3)
a b 1:3
1 1 4 1
2 2 5 2
3 3 6 3
>cbind(数据,'=1:3)
a b
1 1 4 1
2 2 5 2
3 3 6 3
##让你自己看看列名并不是真的空的。。。
>名称(cbind(数据,'=1:3))
[1] a“b”
添加“空”命名列-
“
使用检查数据列前后的对象值。我很惊讶列名没有变为”。我以为cbind.data.frame会调用“check.names”。
> 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" " "