Translated selvitaDigitFormat

This commit is contained in:
Waldir Leoncio 2020-06-24 16:22:25 +02:00
parent fc1b947ca9
commit ec650cc6f6
3 changed files with 49 additions and 0 deletions

31
R/selvitaDigitFormat.R Normal file
View file

@ -0,0 +1,31 @@
#' @title Find out the Digit Format
#' @param line the first line after the "pop" word from data in Genepop format. # @note Function clarified based on the line format whether the alleles of the data are given using 2 or 3 numbers.
#' @return
#' @export
selvitaDigitFormat <- function(line) {
# line on ensimm<6D>inen pop-sanan j<>lkeinen rivi
# Genepop-formaatissa olevasta datasta. funktio selvitt<74><74>
# rivin muodon perusteella, ovatko datan alleelit annettu
# 2 vai 3 numeron avulla.
n <- 1
merkki <- line[n]
while (merkki != ',') {
n <- n + 1
merkki <- line[n]
}
while (!any(merkki == '0123456789')) {
n <- n + 1
merkki <- line[n]
}
numeroja <- 0
while (any(merkki == '0123456789')) {
numeroja <- numeroja + 1
n <- n + 1
merkki <- line[n]
}
df <- numeroja / 2
return(df)
}