Douglass.jl icon indicating copy to clipboard operation
Douglass.jl copied to clipboard

row-wise `if`

Open matthieugomez opened this issue 4 years ago • 2 comments

It seems like it would be nicer to have if as a row-wise operation.

That is, instead of:

d"generate :x = :SepalWidth + :PetalLength if :PetalLength .> 1.3"
d"bysort :Species (:SepalLength) : generate :x = :SepalWidth + :PetalLength if :PetalLength .> 1.3"
d"bysort :Species (:SepalLength) : egen :x = mean(:PetalWidth) if :SepalWidth .< 3.4"

have

d"generate :x = :SepalWidth + :PetalLength if :PetalLength > 1.3"
d"bysort :Species (:SepalLength) : generate :x = :SepalWidth + :PetalLength if :PetalLength > 1.3"
d"bysort :Species (:SepalLength) : egen :x = mean(:PetalWidth) if :SepalWidth < 3.4"

matthieugomez avatar Oct 06 '21 13:10 matthieugomez

Agreed.

jmboehm avatar Oct 07 '21 10:10 jmboehm

I think it is possible to override all binary operators with their elementwise counterparts. There must be a macro for that.

korenmiklos avatar Jan 20 '22 21:01 korenmiklos