为什么这不会导致错误?
> str(u)
'data.frame': 8879 obs. of 2 variables:
$ bundle_qty: int 1 1 1 1 1 1 1 1 1 1 ...
$ mail_a : num 1 1 1 1 0 0 0 1 1 0 ...
> head(u$mail)
[1] 1 1 1 1 0 0
变量mail
不在 data.frameu
中!不应该u$mail
回来NULL
??
即使我从头开始使用虚拟数据:
> rm(list=ls())
> u <- data.frame( bundle_qty = c(1,1,1,1), mail_a = c(1,1,1,1))
> str(u)
'data.frame': 4 obs. of 2 variables:
$ bundle_qty: num 1 1 1 1
$ mail_a : num 1 1 1 1
> u <- data.frame( bundle_qty = c(1L,1L,1L,1L), mail_a = c(1,1,1,1))
> str(u)
'data.frame': 4 obs. of 2 variables:
$ bundle_qty: int 1 1 1 1
$ mail_a : num 1 1 1 1
> u$mail
[1] 1 1 1 1