0

When I create a df like shown below, I can not access value with vol==0.7

shrink[vol==0.7,] does not work, but all the others do.

Can anyone let know what the reason for this might be?

vol <- seq(0,1,0.01)
sh <- 1- vol^(1/3)
shrink <- as.data.frame(cbind(vol=vol,sh))
xmin <- 0.2; xmax <-0.7
ymin <- shrink[vol==xmax,][,2]; ymax <- shrink[vol==xmin,][,2]
p1 <- ggplot(shrink, aes(vol,sh)) + geom_line() + xlim(xmin,xmax)+ ylim(ymin, ymax)
AJPerez
  • 3,257
  • 9
  • 63
  • 87
MarBlo
  • 2,489
  • 12
  • 20
  • `vol[71]#[1] 0.7;vol[71]-0.7#[1] 1.110223e-16` Possibly `FAQ 7.31` – akrun Nov 22 '14 at 15:08
  • @akrun thank you for the comment. But I am not sure, what this means to me. If I do `shrink[vol==0.68,]`I get the right corresponding value. It does not work, if I replace 0.68 by 0.69 or 0.7. It works again starting from 0.71. – MarBlo Nov 22 '14 at 15:28
  • Check this link http://stackoverflow.com/questions/9508518/why-are-these-numbers-not-equal and http://stackoverflow.com/questions/3916439/floating-point-issue-in-c – akrun Nov 22 '14 at 16:03
  • @akrun Great. That was it. I rounded the vector `vol – MarBlo Nov 22 '14 at 16:20

0 Answers0