Skip to content

Commit

Permalink
use dataset improvements, remove RChunks
Browse files Browse the repository at this point in the history
  • Loading branch information
palday committed Sep 13, 2024
1 parent f153a8e commit 4653a99
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 36 deletions.
1 change: 0 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ MixedModelsSim = "d5ae56c5-23ca-4a1f-b505-9fc4796fc1fe"
PooledArrays = "2dfb63ee-cc39-5dd5-95bd-886bf059d720"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
RCall = "6f49c342-dc21-5d91-9882-a32aef131414"
RData = "df47a6cb-8c03-5eed-afd8-b6050d6c41da"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
RegressionFormulae = "545c379f-4ec2-4339-9aea-38f2fb6a8ba2"
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
Expand Down
48 changes: 16 additions & 32 deletions contrasts_kwdyz11.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@ fig-format: png

```{julia}
#| code-fold: true
using AlgebraOfGraphics
using CairoMakie
using Chain
using DataFrames
using MixedModels
using RData: load as rload
using SMLP2024: dataset
using StatsBase
using StatsModels
CairoMakie.activate!(; type="png")
import ProgressMeter
progress = false
```

Expand Down Expand Up @@ -439,7 +438,7 @@ Three factors:
2 x 3 = 6 measures / subject
```{julia}
dat2 = load("data/Exp_2x2x3.rds");
dat2 = dataset(:exp_2x2x3)
```
We select an LMM supported by the data.
Expand Down Expand Up @@ -479,35 +478,20 @@ A: A2 & B: B3 0.523243 0.950202 0.55 0.5819
───────────────────────────────────────────────────────────────────
```
The following figure also appears only in interactive chunk execution. The chunk generates also an error when rendered.
```{r}
#| eval: true
library(tidyverse)
dat2 = readRDS("data/Exp_2x2x3.rds");
cbPalette <- c("#000000", "#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2", "#D55E00", "#CC79A7")
tbl1 <-
dat2 |>
group_by(Subj, A, B) |>
reframe(N=n(),dv=mean(dv)) |>
group_by(A, B) |>
reframe(N=n(), dv_M=mean(dv), dv_SD=sd(dv), dv_SE=dv_SD/sqrt(N))
tbl1
fig1 <-
tbl1 |>
ggplot(aes(y=dv_M, x=B, group=A, color=A)) +
geom_point() +
geom_line() +
scale_color_manual(values=cbPalette[2:3]) +
theme_bw()
print(fig1)
NULL
```{julia}
using Chain
tbl1 = @chain DataFrame(dat2) begin
groupby(_, [:Subj, :A, :B])
combine(_, nrow => :n, :dv => mean => :dv)
groupby(_, [:A, :B])
combine(_,
:dv => mean => :dv_M,
:dv => std => :dv_SD,
:dv => sem => :dv_SE)
end
fig1 = data(tbl1) * mapping(:B, :dv_M; color=:A) * (visual(Lines) + visual(Scatter))
draw(fig1)
```
Expand Down
3 changes: 0 additions & 3 deletions data/Exp_2x2x3.rds

This file was deleted.

0 comments on commit 4653a99

Please sign in to comment.