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

@based_on not working? #17

Closed
bramtayl opened this issue May 27, 2015 · 5 comments
Closed

@based_on not working? #17

bramtayl opened this issue May 27, 2015 · 5 comments

Comments

@bramtayl
Copy link
Contributor

It seems as if DataFrames.based_on has been depreciated? I'm very very new to Julia, so I might just be confused. The error message I get is based_on is not defined. Here is an example:

using RDatasets
iris = dataset("datasets", "iris")

@as _ begin
  iris
  groupby(_, :Species)
  @based_on(_, Mean_Petal_Length = mean(:Petal_Length))
end
@bramtayl bramtayl changed the title @group_by not working? @based_on not working? May 27, 2015
@davidagold
Copy link
Contributor

@bramtayl Have you made sure that you're using the DataFramesMeta package as well as the DataFrames package? @based_on lives in the former. Perhaps a little confusing. You can add the former package by callingPkg.add("DataFramesMeta")`.

@bramtayl
Copy link
Contributor Author

Yes. I checked the source for DataFramesMeta.@based_on, below.

macro based_on(x, args...)
  esc(:( DataFrames.based_on($x, _DF -> DataFramesMeta.@with(_DF, DataFrames.DataFrame($(args...)))) ))
end

However, it looks like DataFrames.based_on has been depreciated as of 0.5.2:

Removes expression-based indexing, including with, within!, based_on, etc.

@davidagold
Copy link
Contributor

Ah, I totally misunderstood your question! I apologize. Are you looking for a way to produce something like:

3x2 DataFrame
| Row | Species      | mean_petal_length |
|-----|--------------|-------------------|
| 1   | "setosa"     | 1.462             |
| 2   | "versicolor" | 4.26              |
| 3   | "virginica"  | 5.552             |

?

@bramtayl
Copy link
Contributor Author

bramtayl commented Jun 1, 2015

Yes, and since I've written my post I've realized this can by done with @by.

@davidagold
Copy link
Contributor

Indeed. Glad to hear. (Also, it's good to wrap macro names in ` s so as not to tag users with the same username as the macro name.)

@bramtayl bramtayl closed this as completed Oct 4, 2015
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