2121# ' # Read sample cultivar file
2222# ' cul <- read_cul(sample_cul_file)
2323# '
24- # '
2524
2625read_cul2 <- function (file_name , col_types = NULL , col_names = NULL ,
2726 left_justified = c(' VAR#' , ' VARNAME\\ .*' , ' VAR-NAME\\ .*' ,' VRNAME\\ .*' ),
@@ -148,19 +147,19 @@ read_sol2 <- function(file_name, id_soil = NULL, nested = TRUE){
148147
149148 # Specify column types
150149 col_types <- readr :: cols(
151- ` LAT` = col_double(),
152- ` LONG` = col_double(),
153- SSAT = col_double(),
154- ` SCS FAMILY` = col_character(),
155- ` SCS Family` = col_character(),
156- SCOM = col_character(),
157- COUNTRY = col_character(),
158- SITE = col_character(),
159- SMHB = col_character(),
160- SMPX = col_character(),
161- SMKE = col_character(),
162- SLMH = col_character(),
163- SLB = col_double()
150+ ` LAT` = col_double(),
151+ ` LONG` = col_double(),
152+ SSAT = col_double(),
153+ ` SCS FAMILY` = col_character(),
154+ ` SCS Family` = col_character(),
155+ SCOM = col_character(),
156+ COUNTRY = col_character(),
157+ SITE = col_character(),
158+ SMHB = col_character(),
159+ SMPX = col_character(),
160+ SMKE = col_character(),
161+ SLMH = col_character(),
162+ SLB = col_double()
164163 )
165164 # {.$cols <- c(.$cols,col_types$cols);.}
166165
@@ -258,18 +257,21 @@ read_sol2 <- function(file_name, id_soil = NULL, nested = TRUE){
258257}
259258
260259
261- # ' Find comment lines
260+ # ' Find comment lines in raw DSSAT file content
262261# '
263- # ' Scans raw lines for comments (lines beginning with "!") and returns them
264- # ' along with their line numbers.
262+ # ' Identifies lines beginning with \code{!} (the DSSAT comment character) in a character vector of raw file content.
265263# '
266- # ' @param raw A character vector where each element is a line of text .
264+ # ' @param raw A character vector where each element represents one line of a DSSAT input file .
267265# '
268- # ' @return A data.frame with two columns: `line_number` (the original index)
269- # ' and `comment_text` (the full text of the comment line).
266+ # ' @return A data frame with two columns:
267+ # ' \describe{
268+ # ' \item{line_number}{Integer index of each comment line within \code{raw}.}
269+ # ' \item{comment_text}{The full text of each comment line.}
270+ # ' }
271+ # ' Returns an empty data frame (zero rows) if no comment lines are found.
270272# '
271273# ' @export
272- # '
274+ # '
273275
274276find_comments <- function (raw ) {
275277
@@ -284,11 +286,26 @@ find_comments <- function(raw) {
284286}
285287
286288
287- # ' Helper function to link comments to pedon
289+ # ' Link soil file comment lines to their respective pedons
288290# '
291+ # ' Associates comment lines found in a DSSAT soil file with the most relevant pedon, combining general
292+ # ' (file-header) comments with pedon-specific ones.
289293# '
290- # ' @noRd
294+ # ' @param comments_lines A data frame as returned by \code{find_comments()}, with columns \code{line_number}
295+ # ' and \code{comment_text}.
296+ # ' @param pedon_start_end A data frame describing pedon extents, with at least columns \code{PEDON} (pedon identifier)
297+ # ' and \code{start} (integer line number where each pedon begins).
291298# '
299+ # ' @details Comment lines appearing before the first pedon are treated as general (file-level) comments and are
300+ # ' prepended to every pedon's comment list. Comment lines appearing after the first pedon start are assigned to
301+ # ' the pedon whose start line is closest (by absolute distance). The combined comments for each pedon are returned
302+ # ' in ascending line-number order.
303+ # '
304+ # ' @return A named list with one element per pedon (named by \code{PEDON}). Each element is a character vector of
305+ # ' comment strings associated with that pedon. Returns an empty list if either input has zero rows.
306+ # '
307+ # ' @noRd
308+ # '
292309
293310link_soil_comments <- function (comments_lines , pedon_start_end ) {
294311
0 commit comments