[R] R annoyances
Philippe Grosjean
phgrosjean at sciviews.org
Fri May 20 15:37:02 CEST 2005
Hello,
Regarding use of parenthesis, it is true that R is much better with
f(10) != f[10] != f[[10]], where Matlab is a little confusing. Also, in
Matlab, you can use some functions without (), further adding to the
confusion (the only example that comes to my mind in R is the use of '?'
as shortcut for help()).
However, there is still a double use of () in R: it is both used for
enclosing function arguments and for grouping operations. One language
has a syntax that makes a totally unambiguous use of [], () and {} is
Mathematica: [] is for subscript, {} is for function arguments and () is
for grouping... but Mathematica code is really a pain to typeset and read.
So, all in all, I really like the S langage syntax: it is very readable
and reasonably rigid...
Regarding T and F, I took the habit to *always* type them TRUE or FALSE.
Again, very readable and not confusing at all. If T and F as equivalent
to TRUE and FALSE would ever be deprecated and then defunct in further
versions of R, well, I would not complain about it!
The only aspect I don't like is a too loosely use of the dot in
functions: both in functions names, in object classes and in generic
functions / methods. Hence, we have for instance: 'data.frame',
'help.search' and 'summary.matrix'... just guess which one is an object
class, which one is an ordinary function and which one is a S3 method
(OK, S4 solves somehow the problem)? It would have been much better to
*reserve* the use of a dot in a function name as a separator between the
name of the generic function and the class to which it applies. Thus,
'summary.matrix' would have been correct, but both 'data.frame' and
'help.search' should have been spelled differently, perhaps 'dataframe'
and 'helpSearch'. Just a dream... because 'data.frame' will of course
never be spelled differently!!!
Best,
Philippe Grosjean
Jan T. Kim wrote:
> On Fri, May 20, 2005 at 08:14:24AM -0400, Liaw, Andy wrote:
>
>>>From: Robin Hankin
>>>
>>>On May 20, 2005, at 11:00 am, Jan T. Kim wrote:
>>>
>>>
>>>>On Thu, May 19, 2005 at 03:10:53PM -0400, John Fox wrote:
>>>>
>>>>
>>>>>Since you can use variables named c, q, or t in any event, I don't
>>>>>see why
>>>>>the existence of functions with these names is much of an
>>>
>>>impediment.
>>>
>>>>True, particularly since I'm not too likely to use these
>>>
>>>variables for
>>>
>>>>(local)
>>>>functions, and variables of other types don't prevent
>>>
>>>functions from
>>>
>>>>working.
>>>>(I thought this was a problem... I must be spoilt by
>>>
>>>recently having
>>>
>>>>to read
>>>>too much Matlab code, where parentheses are used to both enclose
>>>>subscripts and
>>>>parameter lists, thus rendering subscript expressions and function
>>>>calls
>>>>syntactically indistinguishable.)
>>>
>>>
>>>Heh, I'm a recovering Matlab user too. This is sooooooooooo true!
>>>
>>>In Matlab:
>>>
>>>f(10) # function f() evaluated at 10
>>>f(10) # 10th element of vector f. confusing!!
>>>
>>>R uses round brackets in two unrelated ways:
>>>
>>> 4*(1+2) --- using "(" and ")" to signify grouping
>>>f(8) function f() evaluated at 8.
>>>
>>>where there is no reason to use the same parenthesis symbol for both
>>>tasks.
>>
>>The same is done in Fortran/C/C++/Java/Python and God knows how many
>>others...
>
>
> And this is different from the subscripting / function call ambiguity,
> as these languages (to the extent I know them) are designed such that
> parentheses for precedence control are syntactically distinguishable
> from those used for function parameter lists: If the opening parenthesis
> is preceded by an identifier, that identifier is a function name and
> the parenthesis opens a parameter list.
>
> (Python is a somewhat messy case, though, because it uses parentheses
> for tuples too.)
>
> Best regards, Jan
More information about the R-help
mailing list