2020-06-24 16:10:14 +02:00
|
|
|
#' @title Read the Name
|
2020-07-28 12:50:54 +02:00
|
|
|
#' @description Returns the part of the line from the beginning that is before the comma. Useful for returning the name of a GenePop area
|
2020-06-24 16:10:14 +02:00
|
|
|
#' @param line line
|
|
|
|
|
#' @return nimi
|
|
|
|
|
lueNimi <- function(line) {
|
2021-11-10 14:02:35 +01:00
|
|
|
# ==========================================================================
|
|
|
|
|
# Validation
|
|
|
|
|
# ==========================================================================
|
|
|
|
|
if (!grepl(",", line)) {
|
|
|
|
|
stop("There are no commas in this line")
|
|
|
|
|
}
|
|
|
|
|
# Palauttaa line:n alusta sen osan, joka on ennen pilkkua.
|
|
|
|
|
n <- 1
|
|
|
|
|
merkki <- substring(line, n, n)
|
|
|
|
|
nimi <- ""
|
|
|
|
|
while (merkki != ",") {
|
|
|
|
|
nimi <- c(nimi, merkki)
|
|
|
|
|
n <- n + 1
|
|
|
|
|
merkki <- substring(line, n, n)
|
|
|
|
|
}
|
|
|
|
|
return(paste(nimi, collapse = ""))
|
|
|
|
|
}
|