Inspect the teaching data

Broiler feed efficiency

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: 32 Columns: 7
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (3): pen_id, block, diet
dbl (4): birds, feed_kg, gain_kg, fcr

ℹ 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] 32  7
head(data, 6)
# A tibble: 6 × 7
  pen_id block   diet    birds feed_kg gain_kg   fcr
  <chr>  <chr>   <chr>   <dbl>   <dbl>   <dbl> <dbl>
1 Bpen01 block01 control    20    70.7    41.5  1.70
2 Bpen02 block01 BSF        20    79.1    47.1  1.68
3 Bpen03 block01 LMW        20    81.8    45.8  1.79
4 Bpen04 block01 YMW        20    77.5    43.4  1.78
5 Bpen05 block02 control    20    73.1    43.3  1.69
6 Bpen06 block02 BSF        20    79.2    45.8  1.73
str(data)
spc_tbl_ [32 × 7] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
 $ pen_id : chr [1:32] "Bpen01" "Bpen02" "Bpen03" "Bpen04" ...
 $ block  : chr [1:32] "block01" "block01" "block01" "block01" ...
 $ diet   : chr [1:32] "control" "BSF" "LMW" "YMW" ...
 $ birds  : num [1:32] 20 20 20 20 20 20 20 20 20 20 ...
 $ feed_kg: num [1:32] 70.7 79.1 81.8 77.5 73.1 ...
 $ gain_kg: num [1:32] 41.5 47.1 45.8 43.4 43.3 ...
 $ fcr    : num [1:32] 1.7 1.68 1.79 1.78 1.69 ...
 - attr(*, "spec")=
  .. cols(
  ..   pen_id = col_character(),
  ..   block = col_character(),
  ..   diet = col_character(),
  ..   birds = col_double(),
  ..   feed_kg = col_double(),
  ..   gain_kg = col_double(),
  ..   fcr = col_double()
  .. )
 - attr(*, "problems")=<pointer: 0xb12021570> 
# Count missing (NA) values in each column.
colSums(is.na(data))
 pen_id   block    diet   birds feed_kg gain_kg     fcr 
      0       0       0       0       0       0       0 
# Describe the recorded values without fitting an inferential model.
summary(data)
       pen_id         block           diet        birds       feed_kg     
 Length   :32   Length   :32   Length   :32   Min.   :20   Min.   :63.83  
 N.unique :32   N.unique : 8   N.unique : 4   1st Qu.:20   1st Qu.:70.46  
 N.blank  : 0   N.blank  : 0   N.blank  : 0   Median :20   Median :73.72  
 Min.nchar: 6   Min.nchar: 7   Min.nchar: 3   Mean   :20   Mean   :74.12  
 Max.nchar: 6   Max.nchar: 7   Max.nchar: 7   3rd Qu.:20   3rd Qu.:78.28  
                                              Max.   :20   Max.   :82.97  
    gain_kg           fcr       
 Min.   :40.37   Min.   :1.490  
 1st Qu.:41.77   1st Qu.:1.658  
 Median :43.48   Median :1.696  
 Mean   :43.75   Mean   :1.695  
 3rd Qu.:45.50   3rd Qu.:1.746  
 Max.   :48.37   Max.   :1.826  
# Count pens and blocks; diets were assigned to whole pens.
data |>
  summarise(
    recorded_pens = n_distinct(pen_id),
    recorded_blocks = n_distinct(block)
  )
# A tibble: 1 × 2
  recorded_pens recorded_blocks
          <int>           <int>
1            32               8
# Count the recorded pens for each diet within each block.
data |> count(block, diet)
# A tibble: 32 × 3
   block   diet        n
   <chr>   <chr>   <int>
 1 block01 BSF         1
 2 block01 LMW         1
 3 block01 YMW         1
 4 block01 control     1
 5 block02 BSF         1
 6 block02 LMW         1
 7 block02 YMW         1
 8 block02 control     1
 9 block03 BSF         1
10 block03 LMW         1
# ℹ 22 more rows
# 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.