ourMELONS/R/lueNimi.R

17 lines
486 B
R
Raw Normal View History

2020-06-24 16:10:14 +02:00
#' @title Read the Name
#' @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
#' @export
lueNimi <- function(line) {
# Palauttaa line:n alusta sen osan, joka on ennen pilkkua.
n <- 1
merkki <- substring(line, n, n)
2020-06-24 16:10:14 +02:00
nimi <- ''
while (merkki != ',') {
nimi <- c(nimi, merkki)
n <- n + 1
merkki <- substring(line, n, n)
2020-06-24 16:10:14 +02:00
}
return(paste(nimi, collapse=""))
2020-06-24 16:10:14 +02:00
}