Here we show how to generate the ESVAC data on the mg-to-IU and IU-to-mg conversions as well as on the relationship between weight and age.
Installing the required packages:
> required <- c("dplyr", "magrittr", "readr", "readxl", "tidyr")
> to_install <- setdiff(required, row.names(installed.packages()))
> if (length(to_install)) install.packages(to_install)
Loading magrittr
:
> library(magrittr)
Data on chicken weights as a function of age were collected for a previous study. The data are here:
> age_weight_data <- "https://www.dropbox.com/s/5mmw31s2txbmgnx/Supplementary_Data_Frontiers.xlsx?dl=0"
Let’s dowload the excel file:
> tmp <- tempfile(fileext = ".xlsx")
> download.file(sub("dl=0", "raw=1", age_weight_data), tmp)
Let’s transform into a CSV file:
> if (!dir.exists("data")) dir.create("data")
> tmp %>%
+ readxl::read_excel() %>%
+ tidyr::gather("week", "weight.kg", -FlockID, -Chicken) %>%
+ na.exclude() %>%
+ dplyr::mutate(week = sub("Week ", "", week)) %>%
+ dplyr::mutate_at(c("FlockID", "Chicken", "week"), as.integer) %>%
+ write.csv("data/age_weight.csv", quote = FALSE, row.names = FALSE)
The data can now be loaded by:
> age_weight <- readr::read_csv("https://raw.githubusercontent.com/viparc/amu_metrics/master/data/age_weight.csv",
+ col_types = "iiid")