Translated initPopNames
This commit is contained in:
parent
f05f3fdddd
commit
aa9f1c4ef6
4 changed files with 54 additions and 43 deletions
|
|
@ -12,6 +12,7 @@ export(computeRows)
|
|||
export(etsiParas)
|
||||
export(greedyMix)
|
||||
export(handleData)
|
||||
export(initPopNames)
|
||||
export(inputdlg)
|
||||
export(isfield)
|
||||
export(laskeMuutokset4)
|
||||
|
|
|
|||
|
|
@ -1000,49 +1000,6 @@ greedyMix <- function(
|
|||
|
||||
# %-----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
# function popnames = initPopNames(nameFile, indexFile)
|
||||
# %Palauttaa tyhj<68>n, mik<69>li nimitiedosto ja indeksitiedosto
|
||||
# % eiv<69>t olleet yht?pitki?
|
||||
|
||||
# popnames = [];
|
||||
# indices = load(indexFile);
|
||||
|
||||
# fid = fopen(nameFile);
|
||||
# if fid == -1
|
||||
# %File didn't exist
|
||||
# msgbox('Loading of the population names was unsuccessful', ...
|
||||
# 'Error', 'error');
|
||||
# return;
|
||||
# end;
|
||||
# line = fgetl(fid);
|
||||
# counter = 1;
|
||||
# while (line ~= -1) & ~isempty(line)
|
||||
# names{counter} = line;
|
||||
# line = fgetl(fid);
|
||||
# counter = counter + 1;
|
||||
# end;
|
||||
# fclose(fid);
|
||||
|
||||
# if length(names) ~= length(indices)
|
||||
# disp('The number of population names must be equal to the number of ');
|
||||
# disp('entries in the file specifying indices of the first individuals of ');
|
||||
# disp('each population.');
|
||||
# return;
|
||||
# end
|
||||
|
||||
# popnames = cell(length(names), 2);
|
||||
# for i = 1:length(names)
|
||||
# popnames{i,1} = names(i);
|
||||
# popnames{i,2} = indices(i);
|
||||
# end
|
||||
|
||||
|
||||
# %-----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
# %--------------------------------------------------------------------------
|
||||
|
||||
# function logml = ...
|
||||
# initialCounts(partition, data, npops, rows, noalle, adjprior)
|
||||
|
||||
|
|
|
|||
37
R/initPopNames.R
Normal file
37
R/initPopNames.R
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#' @title Initialize Pop Names
|
||||
#' @param nameFile nameFile
|
||||
#' @param indexFile indexFile
|
||||
#' @export
|
||||
initPopNames <- function(nameFile, indexFile) {
|
||||
# Palauttaa tyhj<68>n, mik<69>li nimitiedosto ja indeksitiedosto
|
||||
# eiv<69>t olleet yht?pitki?
|
||||
|
||||
indices <- load(indexFile)
|
||||
|
||||
fid = load(nameFile)
|
||||
if (fid == -1) {
|
||||
# File didn't exist
|
||||
stop('Loading of the population names was unsuccessful')
|
||||
}
|
||||
line <- readLines(fid)[1]
|
||||
counter <- 1
|
||||
names <- vector()
|
||||
while ((line != -1) & (line != "")) {
|
||||
names[counter] <- line
|
||||
line <- readLines(fid)[counter]
|
||||
counter <- counter + 1
|
||||
}
|
||||
|
||||
if (length(names) != length(indices)) {
|
||||
cat('The number of population names must be equal to the number of')
|
||||
cat('entries in the file specifying indices of the first individuals')
|
||||
cat('of each population.')
|
||||
}
|
||||
|
||||
popnames <- cell(length(names), 2)
|
||||
for (i in 1:length(names)) {
|
||||
popnames[i, 1] <- names[i]
|
||||
popnames[i, 2] <- indices[i]
|
||||
}
|
||||
return(popnames)
|
||||
}
|
||||
16
man/initPopNames.Rd
Normal file
16
man/initPopNames.Rd
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/initPopNames.R
|
||||
\name{initPopNames}
|
||||
\alias{initPopNames}
|
||||
\title{Initialize Pop Names}
|
||||
\usage{
|
||||
initPopNames(nameFile, indexFile)
|
||||
}
|
||||
\arguments{
|
||||
\item{nameFile}{nameFile}
|
||||
|
||||
\item{indexFile}{indexFile}
|
||||
}
|
||||
\description{
|
||||
Initialize Pop Names
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue