The R integration in gretl is so good and fast. I am trying to get similar results in
Gretl.
1. summary statistics split by multiple variables
2. Split regression
Gretl has a function summary statistics factorized, but it takes only one variable and one
split variable only.
The following code gives summary statistics for factor variables cyl and am on disp and
mpg, Regression split by cyl.
foreign language=R
pacman::p_load(dplyr, fpp3, purrr, broom)
url =
"https://gist.githubusercontent.com/seankross/a412dfbd88b3db70b74b/raw/5f23f993cd87c283ce766e7ac6b329ee7cc2e1d1/mtcars.csv"
mtcars <- readr::read_csv(url)
#summary statistics by group.
summarise(mtcars, .by = c(cyl, am),
across(
c(mpg, disp),
c(mean = mean, sd = sd, nobs = length)
)
)
# split regression
split(mtcars, mtcars$cyl) |> map(~ lm(mpg ~ disp, data = .)) |>
map(tidy) |> list_rbind(names_to = "id")
end foreign
Finally,
For pipe variable, R studio insert |> upon pressing ctrl+shift+m. Can we have similar
in gretl?
Show replies by date