Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: begin/end blocks working on one dataframe #23

Open
korenmiklos opened this issue Jan 20, 2022 · 2 comments
Open

Feature request: begin/end blocks working on one dataframe #23

korenmiklos opened this issue Jan 20, 2022 · 2 comments

Comments

@korenmiklos
Copy link

korenmiklos commented Jan 20, 2022

Stata syntax:

frame df {
  gen z = SepalLength + SepalWidth
  replace z = _n if _n <= 10
  drop z
  bysort Species : egen z = sum(SepalLength) if SepalWidth > 3.0
}

Intended Julia syntax

@douglas df begin
  gen :z = :SepalLength .+ :SepalWidth
  replace :z = _n if _n <= 10
  drop :z
  bysort :Species : egen :z = sum(:SepalLength) if :SepalWidth .> 3.0
end

Not sure if this is doable as replace etc keywords are neither function call nor macro call.

@jmboehm
Copy link
Owner

jmboehm commented Jan 21, 2022

I guess it could be made to work, but it's not ideal. Julia automatically parses stuff inside the begin/end block into an Expr, and one would have to reconstruct the string inside the begin/end. What would, however, work, is something like

@douglass df """
  gen :z = :SepalLength .+ :SepalWidth
  replace :z = _n if _n <= 10
  drop :z
  bysort :Species : egen :z = sum(:SepalLength) if :SepalWidth .> 3.0
"""

Would this be a good substitute to what you had in mind?

@korenmiklos
Copy link
Author

Because each Stata command begins with a reserved word, these could all be implemented as macros, like @replace, @egen, @merge etc. Like https://juliadata.github.io/DataFramesMeta.jl/stable/

Depends on design choices. Let's discuss on Thursday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants