Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

fix(08_ordinal_reg): use DataFrames.transform! #86

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions _literate/08_ordinal_reg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ using CairoMakie
using AlgebraOfGraphics
using Distributions
using StatsFuns: logit
using DataFrames: transform!

# Here we have a discrete variable `x` with 6 possible ordered values as response.
# The values range from 1 to 6 having probability, respectively:
Expand Down Expand Up @@ -344,7 +343,7 @@ esoph = CSV.read(HTTP.get(url).body, DataFrame)

using CategoricalArrays

transform!(
DataFrames.transform!(
esoph,
:agegp =>
x -> categorical(
Expand All @@ -356,7 +355,7 @@ transform!(
x -> categorical(x; levels=["0-9g/day", "10-19", "20-29", "30+"], ordered=true);
renamecols=false,
)
transform!(esoph, [:agegp, :alcgp, :tobgp] .=> ByRow(levelcode); renamecols=false)
DataFrames.transform!(esoph, [:agegp, :alcgp, :tobgp] .=> ByRow(levelcode); renamecols=false)

X = Matrix(select(esoph, [:agegp, :alcgp]))
y = esoph[:, :tobgp]
Expand Down