Bug 15179 - Expressions with %any% operators do not deparse correctly.
Expressions with %any% operators do not deparse correctly.
Status: CLOSED FIXED
Product: R
Classification: Unclassified
Component: Language
R 2.15.2
All All
: P5 minor
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-01-20 09:05 UTC by Peter Meilstrup
Modified: 2013-01-20 15:38 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Meilstrup 2013-01-20 09:05:11 UTC
Expressions constructed using multiple %any% operators do not deparse with parentheses to preserve the order of operations. 

 x <- 2
 y <- pi
 z <- exp(1)
 `%^%` <- `^`

 expr <- quote( `%^%`(x, `%^%`(y,z)))
 print(expr) # should have parentheses
 eval(expr)
 eval(parse(text=deparse(expr))) #should be the same

interestingly deparsing appears to be correct if the functions are `%*%` or `%/%`, but not for other functions.
Comment 1 Duncan Murdoch 2013-01-20 14:02:23 UTC
Confirmed.  I'll fix it.  The reason %*% and %/% are handled properly is because they are built in operators.  The deparse code handles them separately from user-defined operators.  I'll fix the deparsing to be consistent.
Comment 2 Duncan Murdoch 2013-01-20 15:38:06 UTC
Fixed in R-devel and R-patched