Gurus: I keep seeing other people?s code that contain ideas like If (x == 2L) X[-1L] X - 1L I have some idea of what?s going on, but where is the use of concepts like ?2L? documented? Thanks, Bryan ************* Bryan Hanson Acting Chair Professor of Chemistry & Biochemistry DePauw University, Greencastle IN USA
On Nov 16, 2009, at 6:22 PM, Bryan Hanson wrote:> Gurus: > > I keep seeing other people?s code that contain ideas like > > If (x == 2L) > X[-1L] > X - 1L > > I have some idea of what?s going on, but where is the use of > concepts like > ?2L? documented?Not sure where exactly, and it would depend on where you learned R. The integer data type information and notation should have been found among the material where you learned about "numeric", "character", "logical", .... that sort of basic notion. -- David Winsemius, MD Heritage Laboratories West Hartford, CT
Bryan Hanson wrote:> Gurus: > > I keep seeing other people?s code that contain ideas like > > If (x == 2L) > X[-1L] > X - 1L > > I have some idea of what?s going on, but where is the use of concepts like > ?2L? documented? >In the R Language Definition manual. In this case, look in section 3.1.1, "Constants". Duncan Murdoch> Thanks, Bryan > ************* > Bryan Hanson > Acting Chair > Professor of Chemistry & Biochemistry > DePauw University, Greencastle IN USA > > ______________________________________________ > R-help at 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. >
?NumericConstants will bring up a help page that mentions "All other numeric constants start with a digit or period and are either a decimal or hexadecimal constant optionally followed by L." and "An numeric constant immediately followed by L is regarded as an integer number when possible (and with a warning if it contains a "."). " but I haven't found discussion of it anywhere else in the help pages. Others may know what other help pages discuss this. I'm surprised that the help page invoked from ?integer does not discuss this. Anyone know why not? Best Steve McKinney> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Bryan Hanson > Sent: Monday, November 16, 2009 3:23 PM > To: R Help > Subject: [R] Where are usages like "== 2L" documented? > > Gurus: > > I keep seeing other people?s code that contain ideas like > > If (x == 2L) > X[-1L] > X - 1L > > I have some idea of what?s going on, but where is the use of concepts > like > ?2L? documented? > > Thanks, Bryan > ************* > Bryan Hanson > Acting Chair > Professor of Chemistry & Biochemistry > DePauw University, Greencastle IN USA > > ______________________________________________ > R-help at 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.
Patrick reminded me that it's also in The R Inferno, another document that I need to read again. So now, a more particular semi-question: x <- 1L y <- 1 z <- 1.0 class(x) # integer class(y) # numeric class(z) # numeric x == 1 x == 1L y == 1 z == 1 # all test TRUE Just to clarify, I think the steps above prove it, but *in a test* like x =1 the test is for the contents, not the storage mode, not for a combination of storage mode and contents. So... The reason for defining the notion of "L" is smaller storage space, and more generally, for use anytime one wants explictly an integer for whatever reason? Are there other reasons, for instance, ways it saves lines of code? Bryan ************* Bryan Hanson Acting Chair Professor of Chemistry & Biochemistry DePauw University, Greencastle IN USA On 11/17/09 4:20 AM, "Patrick Burns" <pburns at pburns.seanet.com> wrote:> 'The R Inferno' page 75. > > > > Patrick Burns > patrick at burns-stat.com > +44 (0)20 8525 0696 > http://www.burns-stat.com > (home of "The R Inferno" and "A Guide for the Unwilling S User") > > Bryan Hanson wrote: >> Gurus: >> >> I keep seeing other people?s code that contain ideas like >> >> If (x == 2L) >> X[-1L] >> X - 1L >> >> I have some idea of what?s going on, but where is the use of concepts like >> ?2L? documented? >> >> Thanks, Bryan >> ************* >> Bryan Hanson >> Acting Chair >> Professor of Chemistry & Biochemistry >> DePauw University, Greencastle IN USA >> >> ______________________________________________ >> R-help at 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. >>
Possibly Parallel Threads
- Replacing several rows of a matrix at once
- Definition of "wrapper"?
- Why doesn't vec[-real.number] give an error or warning? Kids do the darndest things!
- Suggestions: Terminology & Pkgs for following spectra over time
- xyplot {lattice} are different types possible for each panel?