Inspect the teaching data

Horse shelter use

Dictionary and design · Analysis plan

What this starter does

These are synthetic teaching observations. The starter imports the supplied CSV and shows its size, columns, missing values and recorded animals or groups. It does not choose a question or fit a model for your group.

Read the dictionary to understand what each row and column represents. The number of recorded rows need not equal the number of animals or groups that received separate treatment assignments or were selected for observation.

Code and executed output

The code below comes directly from the supplied R inspection script. In your instructor-provided Posit Cloud project, open starter.R and run it section by section with this case folder as the working directory. The readr and dplyr packages must be installed. The displayed code loads dplyr and calls readr::read_csv() to import the data.

library("dplyr")

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
# Student project: import and inspect the unchanged synthetic observations.
# Set the working directory to this case folder, or use run-project.R from root.
# readr imports the CSV; dplyr counts the recorded animals and groups.
data <- readr::read_csv("data.csv")
Rows: 336 Columns: 5
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (1): group_id
dbl (4): day, temp_c, horsefly_index, shelter_hours

ℹ 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.
# Show the number of rows and columns, six example rows, and column types.
dim(data)
[1] 336   5
head(data, 6)
# A tibble: 6 × 5
    day group_id temp_c horsefly_index shelter_hours
  <dbl> <chr>     <dbl>          <dbl>         <dbl>
1     1 Hgroup01   24.1           4.88          4.77
2     2 Hgroup01   14.5           2.27          3.07
3     3 Hgroup01   25.8           6.16          4.19
4     4 Hgroup01   21.4           0.31          3.39
5     5 Hgroup01   15.6           1.07          2.42
6     6 Hgroup01   13.4           0             3.03
str(data)
spc_tbl_ [336 × 5] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
 $ day           : num [1:336] 1 2 3 4 5 6 7 8 9 10 ...
 $ group_id      : chr [1:336] "Hgroup01" "Hgroup01" "Hgroup01" "Hgroup01" ...
 $ temp_c        : num [1:336] 24.1 14.5 25.8 21.4 15.6 13.4 25.7 22.1 16.5 21.3 ...
 $ horsefly_index: num [1:336] 4.88 2.27 6.16 0.31 1.07 0 4.58 4.88 1.47 2.69 ...
 $ shelter_hours : num [1:336] 4.77 3.07 4.19 3.39 2.42 ...
 - attr(*, "spec")=
  .. cols(
  ..   day = col_double(),
  ..   group_id = col_character(),
  ..   temp_c = col_double(),
  ..   horsefly_index = col_double(),
  ..   shelter_hours = col_double()
  .. )
 - attr(*, "problems")=<pointer: 0xb8efd95a0> 
# Count missing (NA) values in each column.
colSums(is.na(data))
           day       group_id         temp_c horsefly_index  shelter_hours 
             0              0              0              0              0 
# Describe the recorded values without fitting an inferential model.
summary(data)
      day             group_id       temp_c      horsefly_index 
 Min.   : 1.00   Length   :336   Min.   :13.10   Min.   :0.000  
 1st Qu.: 7.75   N.unique : 12   1st Qu.:16.30   1st Qu.:1.978  
 Median :14.50   N.blank  :  0   Median :19.60   Median :3.230  
 Mean   :14.50   Min.nchar:  8   Mean   :19.49   Mean   :3.255  
 3rd Qu.:21.25   Max.nchar:  8   3rd Qu.:22.62   3rd Qu.:4.572  
 Max.   :28.00                   Max.   :26.00   Max.   :8.000  
 shelter_hours  
 Min.   :1.439  
 1st Qu.:3.318  
 Median :3.953  
 Mean   :3.958  
 3rd Qu.:4.574  
 Max.   :6.525  
# Count pasture groups separately from repeated group-day records.
data |> summarise(recorded_groups = n_distinct(group_id))
# A tibble: 1 × 1
  recorded_groups
            <int>
1              12
# Count the number of daily records from each pasture group.
data |> count(group_id)
# A tibble: 12 × 2
   group_id     n
   <chr>    <int>
 1 Hgroup01    28
 2 Hgroup02    28
 3 Hgroup03    28
 4 Hgroup04    28
 5 Hgroup05    28
 6 Hgroup06    28
 7 Hgroup07    28
 8 Hgroup08    28
 9 Hgroup09    28
10 Hgroup10    28
11 Hgroup11    28
12 Hgroup12    28
# Next: choose a question and submit analysis-plan.qmd in Week 10.
# Create your own analysis script, using class examples for syntax where needed.

Continue with your group’s plan

Use the analysis plan to record your biological question, study design and proposed analysis before fitting the project model. Open analysis-plan.qmd in your supplied project to edit your group’s answers.