jmboehm / Douglass.jl

Stata-like toolkit for data wrangling on Julia DataFrames
Other
51 stars 3 forks source link

row-wise `if` #20

Open matthieugomez opened 3 years ago

matthieugomez commented 3 years ago

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"
jmboehm commented 3 years ago

Agreed.

korenmiklos commented 2 years ago

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