[Rd] Unexpected behaviour of seq(from,to,by) (PR#14057)

From: <raimon.massanet_at_upc.edu>
Date: Wed, 11 Nov 2009 13:15:11 +0100 (CET)


Full_Name: Raimon Massanet
Version: 2.9.2
OS: Linux Ubuntu 8.10
Submission from: (NULL) (147.83.71.76)

# Hi there.
# I'm not sure whether or not this is a bug.

# But it surely is an unexpected behaviour.

V <- seq(from=0,to=1,by=0.1)

# Should generate a sequence with a step of 0.1

V==0
# [1] TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
# Ok!

V==0.1
# [1] FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
# Ok!

V==0.6
# [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
# None?

V[7]
# [1] 0.6

V[7]==0.6
# [1] FALSE
# Rounding!?

V[8]
# [1] 0.7

V[8]==0.7
# [1] FALSE
# Rounding!?

V[9]
# [1] 0.8


V[9]==0.8
# [1] TRUE
# Back to normal

# The generated sequence is fine for all values except for 0.6
# and 0.7, which appear to be somewhat off the expected value.

# According to the R manual the sequence is generated in the form:
# from, from+by, ..., to
# which is not the case.

# Either the function or the documentation lead to an unexpected
# behaviour of seq(from,to,by).

# Thanks!



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 11 Nov 2009 - 12:22:34 GMT

This archive was generated by hypermail 2.2.0 : Wed 11 Nov 2009 - 13:00:24 GMT