Page 1 of 1

Split and Apply

Posted: Tue Oct 21, 2025 7:43 am
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

Re: Split and Apply

Posted: Tue Oct 21, 2025 11:46 pm
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 333 times

Re: Split and Apply

Posted: Wed Oct 22, 2025 6:21 am
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.

Re: Split and Apply

Posted: Wed Oct 22, 2025 10:07 pm
by jonathon
yup ... we've got plans for this.

jonathon