R-lang.pdf has the following description in Section 3.1.1.

"""
Any number typed directly at the prompt is a constant and is evaluated.
> 1
[1] 1
Perhaps unexpectedly, the number returned from the expression 1 is a
numeric. In most
cases, the difference between an integer and a numeric value will be
unimportant as R will
do the right thing when using the numbers.
"""

I'm not sure if I understand it. According to the following example
adding 'L' after '1', doesn't change the mode from 'numeric' to
'integer'. Could somebody clarify this and revise the document to make
this point clearer?

> interogate<-function(f) {
+   print(f(1))
+   x=1
+   print(f(x))
+   x=1L
+   print(f(x))
+   print(f(1L))
+   print(f(as.integer(1)))
+ }
>
> interogate(typeof)
[1] "double"
[1] "double"
[1] "integer"
[1] "integer"
[1] "integer"
> interogate(mode)
[1] "numeric"
[1] "numeric"
[1] "numeric"
[1] "numeric"
[1] "numeric"
> interogate(storage.mode)
[1] "double"
[1] "double"
[1] "integer"
[1] "integer"
[1] "integer"
>

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to