0

I need to left join results of table to generated sequence. Because it did not work as expected (some rows were missing), I tried to compare values in both variables. Why some values of df$c are not equal to values generated using 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
Tomas Greif
  • 21,685
  • 23
  • 106
  • 155

0 Answers0