I?m a PhD student at the University of Warsaw, and have started using R. In many books they specify to use <- instead of = when assigning values, and this is also mentioned in older posts on the R website. However, it seams to me that some update has occured, becuase I continously get the same result wether I use <- or =. I would be extremely helpful for any answer to this. = seams more intuitive, so I assumed that an update had been made due to popular demand and that was why I get the same output wether I use <- or =. Best regards, Petter Hedberg
Dear Petter, Take a look at this post: nabble.com/What-to-use-for-assignment,-"-%3D-"-or-"-<--"--to16521827.html#a16521827<nabble.com/What-to-use-for-assignment,-"-=-"-or-"-<--"--to16521827.html#a16521827> HTH, Jorge On Mon, Dec 15, 2008 at 4:26 PM, Petter Hedberg <ekologkonsult@gmail.com>wrote:> I´m a PhD student at the University of Warsaw, and have started using R. > In many books they specify to use <- instead of = when assigning > values, and this is also mentioned in older posts on the R website. > > However, it seams to me that some update has occured, becuase I > continously get the same result wether I use <- or =. > > I would be extremely helpful for any answer to this. > = seams more intuitive, so I assumed that an update had been made due > to popular demand and that was why I get the same output wether I use > <- or =. > > Best regards, > > Petter Hedberg > > ______________________________________________ > R-help@r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
In most cases <- and = are the same yet its not always true so its safest to use <- for assignment. Check this out: tolstoy.newcastle.edu.au/R/e4/help/08/06/12940.html On Mon, Dec 15, 2008 at 4:26 PM, Petter Hedberg <ekologkonsult at gmail.com> wrote:> I?m a PhD student at the University of Warsaw, and have started using R. > In many books they specify to use <- instead of = when assigning > values, and this is also mentioned in older posts on the R website. > > However, it seams to me that some update has occured, becuase I > continously get the same result wether I use <- or =. > > I would be extremely helpful for any answer to this. > = seams more intuitive, so I assumed that an update had been made due > to popular demand and that was why I get the same output wether I use > <- or =. > > Best regards, > > Petter Hedberg > > ______________________________________________ > R-help at r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
Petter Hedberg wrote:> I?m a PhD student at the University of Warsaw, and have started using R. > In many books they specify to use <- instead of = when assigning > values, and this is also mentioned in older posts on the R website. > > However, it seams to me that some update has occured, becuase I > continously get the same result wether I use <- or =. > > I would be extremely helpful for any answer to this. > = seams more intuitive, so I assumed that an update had been made due > to popular demand and that was why I get the same output wether I use > <- or =. > >czesc, <- and = are not exactly equivalent. while in many situations you may use = instead of <-, in some you can't: x <- 1 x = 1 # same thing foo = function(a) ... foo(x <- 2) # assign to x, and pass it to foo as the argument a foo(x = 2) # pass 2 to foo as the argument x personally, i prefer = to <- wherever possible, but some on this list have expressed the opinion that such code is rather annoying. it seems to be a matter of taste, but you may want to stay in the mainstream and get used to <-. vQ
Thank you all for the reply. I?ll start using <-. Best regards, Petter Hedberg University of Warsaw. 2008/12/16 Gabor Grothendieck <ggrothendieck at gmail.com>:> In most cases <- and = are the same yet its not always > true so its safest to use <- for assignment. > > Check this out: > > tolstoy.newcastle.edu.au/R/e4/help/08/06/12940.html > > On Mon, Dec 15, 2008 at 4:26 PM, Petter Hedberg <ekologkonsult at gmail.com> wrote: >> I?m a PhD student at the University of Warsaw, and have started using R. >> In many books they specify to use <- instead of = when assigning >> values, and this is also mentioned in older posts on the R website. >> >> However, it seams to me that some update has occured, becuase I >> continously get the same result wether I use <- or =. >> >> I would be extremely helpful for any answer to this. >> = seams more intuitive, so I assumed that an update had been made due >> to popular demand and that was why I get the same output wether I use >> <- or =. >> >> Best regards, >> >> Petter Hedberg >> >> ______________________________________________ >> R-help at r-project.org mailing list >> stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> >