hello, I wrote a foreach loop containing "where clauses". R indicates an error in the compilation of the "where clause". Could you please tell me why not right? foreach (series. combine = c)%:% when (mydata [3] = u [1]) % Dopar% (mydata [5] / sum (mydata [5])) L 'error reported by R is: Error: unexpected '=' in "foreach (series. Combine = c)%:% when (mydata [3] =" many thanks in advance Martina [[alternative HTML version deleted]]
On May 14, 2013, at 17:06 , martinizza wrote:> hello, I wrote a foreach loop containing "where clauses". R indicates an > error in the compilation of the "where clause". > Could you please tell me why not right? > > foreach (series. combine = c)%:% when (mydata [3] = u [1]) % Dopar% (mydata > [5] / sum (mydata [5])) > > L 'error reported by R is: > Error: unexpected '=' in "foreach (series. Combine = c)%:% when (mydata [3] > =" >This comes from a package, the package has a maintainer, the maintainer is associated with a commercial company... Anyways, offhand:The comparison operator is == . You likely also need %dopar% (case and spaces do matter). And remove a space and add a comma within the first parenthesis. -- Peter Dalgaard, Professor Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
On 14/05/2013 11:06 AM, martinizza wrote:> hello, I wrote a foreach loop containing "where clauses". R indicates an > error in the compilation of the "where clause". > Could you please tell me why not right? > > foreach (series. combine = c)%:% when (mydata [3] = u [1]) % Dopar% (mydata > [5] / sum (mydata [5])) > > L 'error reported by R is: > Error: unexpected '=' in "foreach (series. Combine = c)%:% when (mydata [3] > ="I don't know foreach, but it looks as though your "=" sign should be "==" to test for equality. The first part looks funny too: shouldn't that be a comma after series, rather than a period? Duncan Murdoch