>>>>> "SM" == Stavros Macrakis <macra...@alum.mit.edu> >>>>> on Wed, 22 Apr 2009 16:30:36 -0400 writes:
SM> Dear R experts, SM> You are being a bit harsh on this user. No! (see below) SM> He simply doesn't understand SM> the distinction between "object of type integer" and "integer-valued SM> object", which is actually fairly subtle. yes, probably for the vast majority of today's R users. *However*, Mauricio submitted a *formal* bug report against R and there are many caveats against doing that "light-heartedly". Note that he also said >> I would really appreciate if you could clarify if this is >> really a bug or not. and that this is exactly one of situation where one should post a question to R-help (or maybe R-devel) but *NOT* submit a formal bug report. Regards, Martin SM> On Wed, Apr 22, 2009 at 1:45 PM, <hzambran.newsgro...@gmail.com> wrote: >> This is a very simple function that seems not to be working, according to the >> definition given by '?is.integer'. SM> ... >>> is.integer(1) >> [1] FALSE >> >> and 1 is obviously an integer value. SM> The is.integer function is correctly documented to check whether SM> objects are of *type* integer, thus: SM> is.integer( 1L ) => TRUE SM> In R, objects of type integer are only created with literals of the SM> form 999L; as the output of some functions when the input is integral SM> (e.g. sort, unique, rev, ...); as the output of some functions which SM> return index values or differences of index values (which, grep, rle, SM> ...); and the output of a few other functions in certain cases (seq). SM> Most numbers in R are floating-point numbers (type double), and SM> determining whether their value is integral is rather subtle. SM> For example, consider the vector 1+1000^-(1:6). In floating-point SM> arithmetic, the first 5 values are distinguishable from the integer 1, SM> but the 6th is not, though of course the *mathematical* number SM> 1+1000^-6 is not integral. Now consider 1e40, which has the property SM> that floor(x)==x==ceiling(x), which you might think characterizes an SM> integer; but it also has the property that x+1 == x. Similarly for SM> 1/3 * 1e40. SM> In other words, it is really a rather subtle question whether a SM> floating-point number "represents" an integer.... SM> -s SM> ______________________________________________ SM> R-devel@r-project.org mailing list SM> https://stat.ethz.ch/mailman/listinfo/r-devel ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel