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

using categorical function inside of @aes/@es/aes doesnt work #126

Open
drizk1 opened this issue Sep 21, 2024 · 1 comment
Open

using categorical function inside of @aes/@es/aes doesnt work #126

drizk1 opened this issue Sep 21, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@drizk1
Copy link
Member

drizk1 commented Sep 21, 2024

Describe the bug
Categorical plotting works now, thank you! but when trying to use something like cat_infreq in @aes it wont work. it has to be applied outside (which is not the end of the world)

ERROR: LoadError: syntax: invalid syntax (escape (outerref cat_infreq))
Stacktrace:
 [1] top-level scope
   @ none:1

To Reproduce

using TidierCats, TidierPlots, TidierData
using Random
Random.seed!(10)
categories = ["High", "Medium", "Low", "Zilch"];
random_indices = rand(1:length(categories), 57);
df = DataFrame(
    ID = 1:57,
    CatVar = categorical([categories[i] for i in random_indices], levels = categories));

ggplot(df) + 
 geom_bar(@aes(x = cat_infreq(CatVar)))

Expected behavior
This is an easy work around to create the needed graph

@chain df begin 
  @mutate(CatVar = cat_infreq(CatVar))
  ggplot(_) + 
  geom_bar(@aes(x = (CatVar)))
end

Screenshots
download-2

Additional context

(@v1.10) pkg> status TidierPlots
Status `~/.julia/environments/v1.10/Project.toml`
  [337ecbd1] TidierPlots v0.8.0
@drizk1 drizk1 added the bug Something isn't working label Sep 21, 2024
@rdboyes
Copy link
Member

rdboyes commented Sep 23, 2024

I'll try to restore something similar - there was some sleight of hand (the function that was being called was actually a callable custom type:

cat_inorder = AesTransform(cat_inorder_fn)
) before to make it work that I pulled out when I rewrote the calculation system

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants