A wrapper for readr's read_csv & readxl's read_excel for reading trial data
Source: R/read_workbooks.R
read_workbooks.RdA wrapper for readr's read_csv & readxl's read_excel for reading trial data
Usage
read_workbooks(
dir = t_dir,
season = NULL,
read_subfolder = FALSE,
s = ".csv|.xlsx",
sub_folder = "Data/Curated Data",
subset = FALSE,
n = NULL,
multiple = FALSE,
sheet_name = NULL,
skip = 0,
file_to_read = NULL,
merge = FALSE,
update_plot = TRUE
)Arguments
- dir
trial data home directory
- season
trial season
- read_subfolder
logical.
TRUEif data lives inside a subfolder inseason- s
a regular expression used to keep relevant files
- sub_folder
character of subfolder containing data e.g
"Data/Curated Data"- subset
ogical.
TRUEif you want to read just a subset of files- n
integer. Number of files to subset e.g,
1,-11:4.- multiple
logical.
TRUEif you want to read nultiple excel sheets from the same workbook- sheet_name
character. used to specify excel sheet name of interest, e.g.,
"fieldbook"- skip
integer. number of rows to skip when reading data from an excel workbook
- file_to_read
character.file name to read e.g., generated by
system.file()- merge
logical. whether or not to merge data from multiple sheets
- update_plot
logical. whether or not to update plot column to conform to SOP. This applies to trials preceeding season 2025.
Examples
f <- system.file("uon-trial-1.csv", package = "pbwrangler")
d <- read_workbooks(dir = NULL, file_to_read = f)
#> Rows: 108 Columns: 32
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr (8): unique, geno, flowering_date, flower_colour, flesh_colour, skin_co...
#> dbl (24): plot, entry, row, col, rep, ntp, npe, growth_speed, pgh, plant_uni...
#>
#> ℹ 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.
lapply(d, function(x) x[1:5, 1:5])
#> $`UON-TRIAL-1`
#> unique plot geno entry row
#> 1 1CIP317004.001 UON-TRIAL-1-00001 CIP317004.001 12 1
#> 2 2CIP317005.036 UON-TRIAL-1-00002 CIP317005.036 14 2
#> 3 3CIP317007.103 UON-TRIAL-1-00003 CIP317007.103 20 3
#> 4 4CIP317013.120 UON-TRIAL-1-00004 CIP317013.120 23 4
#> 5 5CIP317026.004 UON-TRIAL-1-00005 CIP317026.004 28 5
#>