Hey all, I learned that using the equals sign "=" to assign objects is generally OK, but will not work in some cases. As I always use "<-" for assignments, I have not encoutered any problems. Could somebody provide an example or explanation, why getting used to "=" is not a good idea? Or is it? Thanks ahead, Berry ------------------------------------- Berry Boessenkool University of Potsdam, Germany ------------------------------------- [[alternative HTML version deleted]]
I'm not an expert but some third party libraries won't recognize = as an assignment for some objects (I learned this empirically) when the assignment is made within a function. Using <- protects you from these unknows, as you have discovered on your own. Regards David On 6/27/2011 8:34 AM, Berry Boessenkool wrote:> > Hey all, > > I learned that using the equals sign "=" to assign objects is generally OK, but will not work in some cases. > As I always use "<-" for assignments, I have not encoutered any problems. > > Could somebody provide an example or explanation, why getting used to "=" is not a good idea? > Or is it? > > Thanks ahead, > > Berry > > ------------------------------------- > Berry Boessenkool > University of Potsdam, Germany > ------------------------------------- > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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.[[alternative HTML version deleted]]
On 06/27/2011 10:34 AM, Berry Boessenkool wrote:> > > Hey all, > > I learned that using the equals sign "=" to assign objects is generally OK, but will not work in some cases. > As I always use "<-" for assignments, I have not encoutered any problems. > > Could somebody provide an example or explanation, why getting used to "=" is not a good idea? > Or is it? > > Thanks ahead, > > Berry >As a top-level expression, it probably doesn't matter too much. I always use <- myself. Here is an example where = does not equal <- print(fit <- lm(...)) is very different from print(fit = lm(...)). -- Kevin E. Thorpe Biostatistician/Trialist, Applied Health Research Centre (AHRC) Li Ka Shing Knowledge Institute of St. Michael's Assistant Professor, Dalla Lana School of Public Health University of Toronto email: kevin.thorpe at utoronto.ca Tel: 416.864.5776 Fax: 416.864.3016
On Mon, Jun 27, 2011 at 10:34 AM, Berry Boessenkool <berryboessenkool at hotmail.com> wrote:> > > Hey all, > > I learned that using the equals sign "=" to assign objects is generally OK, but will not work in some cases. > As I always use "<-" for assignments, I have not encoutered any problems. > > Could somebody provide an example or explanation, why getting used to "=" is not a good idea? > Or is it? >See this thread: https://mailman.stat.ethz.ch/pipermail/r-help/2008-January/151538.html -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com