From suharto_anggono at yahoo.com  Mon Sep  3 11:06:56 2012
From: suharto_anggono at yahoo.com (Suharto Anggono Suharto Anggono)
Date: Mon, 3 Sep 2012 02:06:56 -0700 (PDT)
Subject: [Rd] Typo (?) in 'aggregate.formula'
Message-ID: <1346663216.98684.YahooMailClassic@web125102.mail.ne1.yahoo.com>

In the code for 'aggregate.formula', there is
if (as.character(formula[[2L]] == "."))
I believe that it is meant to be
if (as.character(formula[[2L]]) == ".")

However,
if (as.character(formula[[2L]] == "."))
gives the expected result.
Tracing:
- formula[[2L]] == "."
is equivalent to
as.character(formula[[2L]]) == "."
From the help page for '==' (Comparison), "Language objects such as symbols and calls are deparsed to character strings before comparison."
- By applying 'as.character', the TRUE/FALSE result of
formula[[2L]] == "."
is converted to character, becomes "TRUE"/"FALSE".
- Then, for 'if', it is implicitly converted back to logical.


> sessionInfo()
R version 2.14.2 (2012-02-29)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     


I see that, in R 2.15.1, the code for 'aggregate.formula' is still the same.



[Rd] Typo (?) in 'aggregate.formula'
Suharto Anggono Suharto Anggono