我需要将table
的联接结果留给生成的序列。因为它没有按预期工作(某些行丢失),我试图比较两个变量中的值。为什么df$c
的某些值不等于使用seq()
生成的值?
# Sample data
a <- runif(100)
b <- runif(100) > .5
step <- .1
# This is what I do in my real task
df <- as.data.frame.matrix(table(trunc(a / step) * step, b))
df$c <- as.numeric(rownames(df))
# Would like to join, but comparsion of df$c and generated sequence
# return FALSE for some elements.
df$c == seq(0, 0.9, step)
# Returns> [1] TRUE TRUE TRUE FALSE TRUE TRUE FALSE FALSE TRUE TRUE