Split and Apply

General help and assistance with jamovi. Bug reports can be made at our issues page: https://github.com/jamovi/jamovi/issues . (If you're unsure feel free to discuss it here)
Post Reply
srk80
Posts: 12
Joined: Sat Mar 18, 2023 7:37 am

Split and Apply

Post by srk80 »

Hi,

I would like to split my mycars dataset into three subsets based on the cyl variable and apply linear regression on each of these datasets. Is there any way I can do this? Similar R code to achieve this is:

models1 = lapply(split(mtcars, mtcars$cyl), \(x)lm(mpg ~ disp, data = x))
tidy_list = lapply(models1, tidy)
tidy_list
User avatar
jonathon
Posts: 2898
Joined: Fri Jan 27, 2017 10:04 am

Re: Split and Apply

Post by jonathon »

there's not a neat way to do this at this time unfortunately ... but you can do something like:


Screenshot 2025-10-22 at 10.44.55.png
Screenshot 2025-10-22 at 10.44.55.png (504.48 KiB) Viewed 274 times
srk80
Posts: 12
Joined: Sat Mar 18, 2023 7:37 am

Re: Split and Apply

Post by srk80 »

I know this method, but I would like to see the combined data in one place. lme4 or nlme got a neat function lmList which achieves exactly this. In future, I would like jamovi should have this capacity to split the data and apply t-test, anova, lm etc and get combined results. I have seen this capability in bluesky statistics.
User avatar
jonathon
Posts: 2898
Joined: Fri Jan 27, 2017 10:04 am

Re: Split and Apply

Post by jonathon »

yup ... we've got plans for this.

jonathon
Post Reply