I've been asked to create an R script that can calculate z-scores for var1 grouped by var2. Jamovi does this really easily using the compute function "Z(var1, group_by=var2)". But how does it do the grouping? I've been searching for 2 hours how to script this in R and I can't find a script that works
Any chance we could share the underlying code that jamovi is using to calculate the grouped z-scores?
How does jamovi calculate grouped z-scores?
Re: How does jamovi calculate grouped z-scores?
Hi, @jmjamison.jmjamison wrote: Any chance we could share the underlying code that jamovi is using to calculate the grouped z-scores?
Take a look at this screenshot if that's what you're looking for. Cheers,
Maurizio
Re: How does jamovi calculate grouped z-scores?
mz's your man,
the group_by stuff is actually implemented in python, and it's implemented as part of a complex AST system, so it's not simply a few lines of code you can copy/paste unfortunately.
but mz's solution is your ticket.
cheers
jonathon
the group_by stuff is actually implemented in python, and it's implemented as part of a complex AST system, so it's not simply a few lines of code you can copy/paste unfortunately.
but mz's solution is your ticket.
cheers
jonathon
Re: How does jamovi calculate grouped z-scores?
Wow, I didn't even know that we use Python under the hood. Makes sense and answers a few questions. Thanks @jonathon
And thanks @MAgojam for going the extra mile and creating a usable script for R. You have a really clean logic in your script. Unfortunately, my dataset has >1400 groups, so I'll need to automate the grouping. But you gave me the idea to test a few methods using a toy dataset like yours, and one started working. So I think I'll have to debug my data cleaning before I'm able to solve my standardization by groups anyway. Thanks for your input
And thanks @MAgojam for going the extra mile and creating a usable script for R. You have a really clean logic in your script. Unfortunately, my dataset has >1400 groups, so I'll need to automate the grouping. But you gave me the idea to test a few methods using a toy dataset like yours, and one started working. So I think I'll have to debug my data cleaning before I'm able to solve my standardization by groups anyway. Thanks for your input