Re: [R] R is GNU S, not C.... [was "how to get or store ....."]

From: Philippe Grosjean <phgrosjean_at_sciviews.org>
Date: Wed 07 Dec 2005 - 12:06:58 EST

Hello,

About the "R style war": as soon as you write code for yourself, you can do what you want, of course. If your code is shared (for instance, code in packages submitted to CRAN), it makes sense to render it so that it is easier to read *by a majority of people*. The only way to make sure it is easy to read by most people is to follow strictly the style proposed by the R core team (even if you don't like it)!

So, if you write both code for yourself and for public release, and/or if you think that your code will become public one day, it is better to follow R core team style from the beginning. Similarly, you should never use T/F instead of TRUE/FALSE in code that will go to a library ('cause you'll have to change it anyway)... So, why not to take the habit to write TRUE/FALSE all the time in your code?

The conclusion: it is far better to strictly follow R core team style for *all* code (your own plus the one your share), because it is easier to stick on one style... and, don't worry, you will gradually become accustomished to the aspects you don't like in that style.

So, who said there is an "R style war"? There is one set of rules to follow. Point. Don't you have better things to do that to discuss if one needs a space here (a <- 1), or not (a<-1) ?

Best,

Philippe Grosjean

Patrick Connolly wrote:
> On Tue, 06-Dec-2005 at 01:00PM +0000, Adaikalavan Ramasamy wrote:
>
> |> Yes, it drives me mad too when people use "=" instead of "<-" for
> |> assignment and suppress spaces in an naive attempt for saving space.
> |>
> |> As an example compare
> |>
> |> o=fn(x=1,y=10,z=1)
> |>
> |> with
> |>
> |> o <- fn( x=1, y=10, z=1 )
>
>
> Or better still:
>
> o <- fn(x = 1, y = 10, z = 1)
>
> The effect is more marked when the arguments are whole words rather
> than the single letter names in this example.
>
> Compare
>
> o <- fn(xena = log, yacht = 10625, zebra = "green")
>
> with
>
> o <- fn( xena=log, yacht=10625, zebra="green" )
>
>
>
>
> |>
> |> Regards, Adai
> |>
> |>
> |>
> |> On Tue, 2005-12-06 at 13:43 +0100, Martin Maechler wrote:
> |> > >>>>> "vincent" == vincent <vincent@7d4.com>
> |> > >>>>> on Tue, 06 Dec 2005 11:09:36 +0100 writes:
> |> >
> |> > vincent> shanmuha boopathy a écrit :
> |> > >> a<-function(a,b,c,d)
> |> > >> {
> |> > >> k=a+b
> |> > >> l=c+d
> |> > >> m=k+l
> |> > >> }
> |> > >>
> |> > >> in this example the function will return only the value of "m"
> |> > >> ...But I like to extract the values of "l" & "k" also.........
> |> > >> which command to use for storing or for extracting those intermediate value.......
> |> >
> |> > vincent> may I suggest, inside your function
> |> >
> |> > vincent> res = c(k, l, m);
> |> > vincent> return(res);
> |> >
> |> > please, please, these trailing ";" are *so* ugly.
> |> > This is GNU S, not C (or matlab) !
> |> >
> |> > {and I have another chain of argments why "<-" is so more
> |> > expressive than "=" but I'll be happy already if you could
> |> > drop these ugly empty statements at the end of your lines...
> |> >
> |> > vincent> # also ... read some intro docs !
> |> >
> |> > ______________________________________________
> |> > R-help@stat.math.ethz.ch mailing list
> |> > https://stat.ethz.ch/mailman/listinfo/r-help
> |> > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> |> >
> |>
> |> ______________________________________________
> |> R-help@stat.math.ethz.ch mailing list
> |> https://stat.ethz.ch/mailman/listinfo/r-help
> |> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Dec 07 12:20:33 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:30 EST