Skip to content

Instantly share code, notes, and snippets.

@cbaragao
Last active October 8, 2025 21:50
Show Gist options
  • Select an option

  • Save cbaragao/d46afc5a9ea1f0bc98b2d8757c7c6597 to your computer and use it in GitHub Desktop.

Select an option

Save cbaragao/d46afc5a9ea1f0bc98b2d8757c7c6597 to your computer and use it in GitHub Desktop.
(df as table, independent as text, dependent as text)=>
let
Source =
R.Execute(
"df <- dataset " &
"#(lf)logit <- glm(" & dependent & " ~ " & independent & ", data = df, family = ""binomial"")" &
"#(lf)df$Predicted <- predict(logit, newdata = df, type = ""response"")" &
"#(lf)df$Prediction <- ifelse(df$Predicted > 0.5, 1, 0)" &
"#(lf)df", [dataset=df]),
Return = Source{[Name="df"]}[Value]
in
Return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment