A wrapper for readr
's read_csv
& readxl
's read_excel
for reading trial data
Source: R/read_workbooks.R
read_workbooks.Rd
A 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
)
Arguments
- dir
trial data home directory
- season
trial season
- read_subfolder
logical.
TRUE
if 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.
TRUE
if you want to read just a subset of files- n
integer. Number of files to subset e.g,
1
,-1
1:4
.- multiple
logical.
TRUE
if 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
clogical. whether or not to merge data from multiple sheets
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 1 CIP317004.001 12 1
#> 2 2CIP317005.036 2 CIP317005.036 14 2
#> 3 3CIP317007.103 3 CIP317007.103 20 3
#> 4 4CIP317013.120 4 CIP317013.120 23 4
#> 5 5CIP317026.004 5 CIP317026.004 28 5
#>