Longitudinale opdracht course 3

Author

zet hier de namen van alle auteurs

Published

April 9, 2026

Read data

Afhankelijk van de data bestand zullen je een code moeten kiezen om je data in te lezen.

library(readr)
data_test <- read_csv2("data test.csv")
ℹ Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
New names:
Rows: 18 Columns: 36
── Column specification
──────────────────────────────────────────────────────── Delimiter: ";" chr
(19): Student or teacher of EBPiHC (0/1), Gender (0/1), Weight (kg), Int... dbl
(17): Study number, Age (years), Length (cm), BMI (kg/m2), Hours of slee...
ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
Specify the column types or set `show_col_types = FALSE` to quiet this message.
• `How many hours ago` -> `How many hours ago...23`
• `How many hours ago` -> `How many hours ago...27`
View(data_test)

DMV head een data test uitvoeren

head(data_test)
# A tibble: 6 × 36
  `Study number` Student or teacher of EBPiHC (0/…¹ `Gender (0/1)` `Age (years)`
           <dbl> <chr>                              <chr>                  <dbl>
1              1 Niet ingevuld?                     Niet ingevuld             27
2              2 Niet ingevuld?                     Niet ingevuld             54
3              3 Niet ingevuld?                     1                         43
4              4 Niet ingevuld?                     Niet ingevuld             52
5              5 Niet ingevuld?                     1                         29
6              6 0                                  1                         28
# ℹ abbreviated name: ¹​`Student or teacher of EBPiHC (0/1)`
# ℹ 32 more variables: `Weight (kg)` <chr>, `Length (cm)` <dbl>,
#   `BMI (kg/m2)` <dbl>, `Hours of sleep last night (0/1/2)` <dbl>,
#   `Score of sleep (0-10)` <dbl>, `Sleep interruptions (0/1)` <dbl>,
#   `Interruptions (number)` <chr>, `Sleep issues (0/1/2/3/4)` <chr>,
#   `Sleep disorders (0/1)` <dbl>, `Sort sleep disorder` <chr>,
#   `Medication to fall asleep (0/1)` <chr>, …

mbv prompt R data kolommen laten lezen middels kort benaming waardoor alles tussen haakjes wordt genegeerd als misleidende termen

colnames(data_test)[colnames(data_test) == "Weight (kg)"] <- "Weight"
colnames(data_test)[colnames(data_test) == "Length (cm))"] <- "Length"
colnames(data_test)[colnames(data_test) == "BMI (kg/m2)"] <- "BMI"
colnames(data_test)[colnames(data_test) == "Score of sleep (0-10)"] <- "SleepScore"

{r} table1(~ Weight + Length (cm) + BMI + SleepScore, data = data_test)


# Table1 format genereren door R via prompt over gekozen onderwerpen

{r}
table1(~ Weight + `Length (cm)` + BMI + SleepScore + `Hours of sleep last night (0/1/2)`, 
       data = data_test)


# R instrueren de data uit de kolom hours of sleep te zien als factoren en niet numeriek


::: {.cell}

```{.r .cell-code}
data_test$`Hours of sleep last night (0/1/2)` <- factor(
  data_test$`Hours of sleep last night (0/1/2)`,
  levels = c(0, 1, 2),
  labels = c("> 4-6 uur", "6-8 uur", "> 8 uur")
)

:::

hernieuwde poging Table1 met hours of sleep als factor

library(table1)
Warning: package 'table1' was built under R version 4.5.3

Attaching package: 'table1'
The following objects are masked from 'package:base':

    units, units<-
table1(~ Weight + `Length (cm)` + BMI + SleepScore + `Hours of sleep last night (0/1/2)`, 
       data = data_test)
Overall
(N=18)
Weight
- 1 (5.6%)
120 1 (5.6%)
50 1 (5.6%)
52 1 (5.6%)
53 1 (5.6%)
55 1 (5.6%)
60 1 (5.6%)
65 1 (5.6%)
67 1 (5.6%)
68 1 (5.6%)
69 1 (5.6%)
70 1 (5.6%)
75 1 (5.6%)
85 1 (5.6%)
86 1 (5.6%)
90 1 (5.6%)
91 1 (5.6%)
Missing 1 (5.6%)
Length (cm)
Mean (SD) 172 (11.6)
Median [Min, Max] 170 [155, 198]
BMI
Mean (SD) 24.0 (4.00)
Median [Min, Max] 22.9 [19.1, 31.9]
Missing 2 (11.1%)
SleepScore
Mean (SD) 5.76 (1.58)
Median [Min, Max] 6.00 [2.00, 8.00]
Hours of sleep last night (0/1/2)
> 4-6 uur 9 (50.0%)
6-8 uur 8 (44.4%)
> 8 uur 1 (5.6%)
label(data_test$`Hours of sleep last night (0/1/2)`) <- "Slaapduur per nacht"
label(data_test$SleepScore) <- "Slaapkwaliteit Score"
label(data_test$`Hours of sleep last night (0/1/2)`) <- "Slaapduur per nacht"
label(data_test$SleepScore) <- "Slaapkwaliteit Score"
library(table1)

table1(~ Weight + `Length (cm)` + BMI + SleepScore + `Hours of sleep last night (0/1/2)`, 
       data = data_test)
Overall
(N=18)
Weight
- 1 (5.6%)
120 1 (5.6%)
50 1 (5.6%)
52 1 (5.6%)
53 1 (5.6%)
55 1 (5.6%)
60 1 (5.6%)
65 1 (5.6%)
67 1 (5.6%)
68 1 (5.6%)
69 1 (5.6%)
70 1 (5.6%)
75 1 (5.6%)
85 1 (5.6%)
86 1 (5.6%)
90 1 (5.6%)
91 1 (5.6%)
Missing 1 (5.6%)
Length (cm)
Mean (SD) 172 (11.6)
Median [Min, Max] 170 [155, 198]
BMI
Mean (SD) 24.0 (4.00)
Median [Min, Max] 22.9 [19.1, 31.9]
Missing 2 (11.1%)
Slaapkwaliteit Score
Mean (SD) 5.76 (1.58)
Median [Min, Max] 6.00 [2.00, 8.00]
Slaapduur per nacht
> 4-6 uur 9 (50.0%)
6-8 uur 8 (44.4%)
> 8 uur 1 (5.6%)

aanpassing Table1, naar lengte gewicht BMI, hours of sleep en sleepscore

data_test$`Hours of sleep last night (0/1/2)` <- factor(
  data_test$`Hours of sleep last night (0/1/2)`,
  levels = c(0, 1, 2),
  labels = c("< 6 uur", "6-8 uur", "> 8 uur")
)

library(table1)

table1(~ Weight + `Length (cm)` + BMI + SleepScore + `Hours of sleep last night (0/1/2)`, 
       data = data_test)
Overall
(N=18)
Weight
- 1 (5.6%)
120 1 (5.6%)
50 1 (5.6%)
52 1 (5.6%)
53 1 (5.6%)
55 1 (5.6%)
60 1 (5.6%)
65 1 (5.6%)
67 1 (5.6%)
68 1 (5.6%)
69 1 (5.6%)
70 1 (5.6%)
75 1 (5.6%)
85 1 (5.6%)
86 1 (5.6%)
90 1 (5.6%)
91 1 (5.6%)
Missing 1 (5.6%)
Length (cm)
Mean (SD) 172 (11.6)
Median [Min, Max] 170 [155, 198]
BMI
Mean (SD) 24.0 (4.00)
Median [Min, Max] 22.9 [19.1, 31.9]
Missing 2 (11.1%)
Slaapkwaliteit Score
Mean (SD) 5.76 (1.58)
Median [Min, Max] 6.00 [2.00, 8.00]
Hours of sleep last night (0/1/2)
< 6 uur 0 (0%)
6-8 uur 0 (0%)
> 8 uur 0 (0%)
Missing 18 (100%)

``{r} data_test <- read.csv(“datatest.csv”)


## Data cleaning, komen tot een definitieve data set.

Zorg dat u data set op orde komt voor het doen van een analyse.

Schrijf hier kort de uitleg van uw hercodeer of cleaning stap die u in de onderstaande r-chunk uitvoert (wat doet u en/of waarom).


::: {.cell}

```{.r .cell-code}
library(readr)
Code_boek_test <- read_csv2("C:/EBPiHC/R Studio documenten en projecten/Course3/Code boek test.csv")
ℹ Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
Rows: 5 Columns: 32
── Column specification ────────────────────────────────────────────────────────
Delimiter: ";"
chr (31): Student or teacher of EBPiHC (0/1), Gender (0/1), Age (years), Wei...
lgl  (1): Study number

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
View(Code_boek_test)

:::

library(readr)
data_test <- read_csv2("data test.csv")
ℹ Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
New names:
Rows: 18 Columns: 36
── Column specification
──────────────────────────────────────────────────────── Delimiter: ";" chr
(19): Student or teacher of EBPiHC (0/1), Gender (0/1), Weight (kg), Int... dbl
(17): Study number, Age (years), Length (cm), BMI (kg/m2), Hours of slee...
ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
Specify the column types or set `show_col_types = FALSE` to quiet this message.
• `How many hours ago` -> `How many hours ago...23`
• `How many hours ago` -> `How many hours ago...27`
View(data_test)

..

library(car)
Loading required package: carData
library(tidyverse)
Warning: package 'tidyverse' was built under R version 4.5.3
Warning: package 'lubridate' was built under R version 4.5.3
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.2.0     ✔ purrr     1.2.1
✔ forcats   1.0.1     ✔ stringr   1.6.0
✔ ggplot2   4.0.2     ✔ tibble    3.3.1
✔ lubridate 1.9.5     ✔ tidyr     1.3.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
✖ dplyr::recode() masks car::recode()
✖ purrr::some()   masks car::some()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(tidyplots)
glimpse(data_test)
Rows: 18
Columns: 36
$ `Study number`                                        <dbl> 1, 2, 3, 4, 5, 6…
$ `Student or teacher of EBPiHC (0/1)`                  <chr> "Niet ingevuld?"…
$ `Gender (0/1)`                                        <chr> "Niet ingevuld",…
$ `Age (years)`                                         <dbl> 27, 54, 43, 52, …
$ `Weight (kg)`                                         <chr> "67", "120", "69…
$ `Length (cm)`                                         <dbl> 175, 198, 171, 1…
$ `BMI (kg/m2)`                                         <dbl> 21.9, 30.6, 23.6…
$ `Hours of sleep last night (0/1/2)`                   <dbl> 2, 0, 1, 0, 0, 0…
$ `Score of sleep (0-10)`                               <dbl> 7.0, 6.0, 5.0, 5…
$ `Sleep interruptions (0/1)`                           <dbl> 0, 0, 0, 0, 0, 1…
$ `Interruptions (number)`                              <chr> "1", "1", "2", "…
$ `Sleep issues (0/1/2/3/4)`                            <chr> "4", "3", "3", "…
$ `Sleep disorders (0/1)`                               <dbl> 1, 1, 0, 1, 1, 1…
$ `Sort sleep disorder`                                 <chr> "Nvt", "Nvt", "l…
$ `Medication to fall asleep (0/1)`                     <chr> "1", "1", "1", "…
$ `Supplements or herbs to improve sleep (0/1)`         <chr> "1", "1", "1", "…
$ `Night shifts (0/1)`                                  <dbl> 0, 1, 0, 1, 1, 1…
$ `Did your night shift end in the last 48 hour? (0/1)` <chr> "1", "Nvt", NA, …
$ `Sport (0/1)`                                         <dbl> 0, 0, 0, 1, 0, 0…
$ `Freqency of sport/week`                              <chr> "3", "3", "3-4-"…
$ `Kind of sport`                                       <chr> "Krachttraining …
$ `Cafeine intake (0/1)`                                <dbl> 0, 0, 1, 0, 0, 0…
$ `How many hours ago...23`                             <chr> "1 minuut gelede…
$ `Amount of cafeine`                                   <chr> "1x cola", "3x z…
$ `Alcohol/drugs (0/1)`                                 <dbl> 1, 0, 1, 1, 1, 1…
$ `What kind of alcohol?`                               <chr> "Nvt", "33 cl Be…
$ `How many hours ago...27`                             <chr> "Nvt", "23", "Nv…
$ `Medication/supplements affecting reaction time`      <dbl> 1, 1, 1, 1, 1, 1…
$ `Other factors affecting reaction time`               <chr> "Jetlag", "1", "…
$ `Dominant hand`                                       <chr> "Rechts", "Recht…
$ `Measurement 1 (ms)`                                  <dbl> 289, 297, 327, 3…
$ `Measurement 2 (ms)`                                  <dbl> 295, 332, 273, 4…
$ `Measurement 3 (ms)`                                  <dbl> 305, 417, 275, 3…
$ `Average (ms)`                                        <dbl> 296, 349, 292, 3…
$ `Factors/events affecting measurements`               <chr> "Geen oefenmetin…
$ `All questions answered?`                             <chr> "No", "No", "Yes…
head(Code_boek_test)
# A tibble: 5 × 32
  `Study number` Student or teacher of EBPiHC (0/…¹ `Gender (0/1)` `Age (years)`
  <lgl>          <chr>                              <chr>          <chr>        
1 NA             0 = ja                             0 = man        Getal        
2 NA             1 = nee                            1 = vrouw      <NA>         
3 NA             <NA>                               <NA>           <NA>         
4 NA             <NA>                               <NA>           <NA>         
5 NA             <NA>                               <NA>           <NA>         
# ℹ abbreviated name: ¹​`Student or teacher of EBPiHC (0/1)`
# ℹ 28 more variables: `Weight (kg)` <chr>, `Length (cm)` <chr>,
#   `BMI (kg/m2)` <chr>, `Hours of sleep last night (0/1/2)` <chr>,
#   `Score of sleep (0-10)` <chr>, `Sleep interruptions (0/1)` <chr>,
#   `Interruptions (number)` <chr>, `Sleep issues (0/1/2/3/4)` <chr>,
#   `Sleep disorders (0/1)` <chr>, `Medication to fall asleep (0/1)` <chr>,
#   `Supplements or herbs to improve sleep (0/1)` <chr>, …

herhaal deze stappen voor elke volgende codeer stap..

Uitvoeren analyses die nodig zijn om uw sample te beschrijven en uw onderzoeksvraag te beanwoorden.

Schrijf hier kort de uitleg van uw analysestap die u in de onderstaande r-chunk uitvoert (wat doet u en/of waarom {r} # schrijf hier de benodigde R-code ```

Schrijf hier uw interpretatie van de analyse die in bovenstaande r-chunk is uitgevoerd.

..herhaal deze stappen voor elke volgende analysestap..

Short report

Introduction (course 2)

Copy your introduction section from course 2 and paste it here.

Methode (course 2)

Copy your method section from course 2 and paste it here.

NoteStatistical Analysis

Write your statistical analysis paragraph here

NoteResults

Write your result paragraph here

NoteConclusion

Write your conclusion paragraph here