After rereading Rui Barrades's reply, I was able to get "lm" object from
data.table
carsreg3 <- carsdt[, .(fit = list(lm(mpg ~ disp + hp + wt))), by = .(cyl)]
carsreg3[, .N]
#[1] 3
carsreg3[(cyl == 6), .(fit)][[1]][[1]] |> class()
#[1] "lm"
carsreg3[(cyl == 6), .(fit)][[1]][[1]] |> summary()
car
В Sun, 22 Sep 2024 07:44:16 -0400
Naresh Gurbuxani пишет:
> carsreg <- carsdt[, .(fit = lm(mpg ~ disp + hp + wt)), by = .(cyl)]
>
> #I would like a data.table with three rows, one each for "lm" object
> corresponding to cyl value
>
> carsreg[, .N]
> #[1] 36
Try wrapping the lm() expression in
Thanks everyone for their responses.
My data is organized in a data.table. My goal is to perform analyses
according to some groups. The results of analysis are objects. If
these objects could be stored as elements of a data.table, this would
help downstream summarizing of results.
Let me
3 matches
Mail list logo