Skip to content

Commit

Permalink
set stringsAsFactors = FALSE in poppr() fun
Browse files Browse the repository at this point in the history
This will address #212
  • Loading branch information
zkamvar committed Feb 19, 2020
1 parent b90f9b7 commit 6f26ecc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
5 changes: 3 additions & 2 deletions R/Index_calculations.r
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ poppr <- function(dat, total = TRUE, sublist = "ALL", blacklist = NULL,
Hexp,
IaList,
File = namelist$File
)
),
stringsAsFactors = FALSE
)
rownames(Iout) <- NULL
} else {
Expand Down Expand Up @@ -451,7 +452,7 @@ poppr <- function(dat, total = TRUE, sublist = "ALL", blacklist = NULL,
Hexp,
as.data.frame(t(IaList)),
File = namelist$File
))
), stringsAsFactors = FALSE)
rownames(Iout) <- NULL
}
class(Iout) <- c("popprtable", "data.frame")
Expand Down
13 changes: 5 additions & 8 deletions tests/testthat/test-poppr.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ A.tab <- poppr(Aeut, quiet = TRUE)
afile <- system.file("files/rootrot.csv", package = "poppr")
sims <- system.file("files/simulated.dat", package = "poppr")

Aeut_comparison <- structure(list(Pop = structure(1:3,
.Label = c("Athena", "Mt. Vernon", "Total"),
class = "factor"),
Aeut_comparison <- structure(list(Pop = c("Athena", "Mt. Vernon", "Total"),
N = c(97, 90, 187),
MLG = c(70, 50, 119),
eMLG = c(65.9808393377379, 50, 68.4525682280634),
Expand All @@ -21,13 +19,12 @@ Aeut_comparison <- structure(list(Pop = structure(1:3,
Hexp = c(0.169711892488954, 0.158016764758338, 0.365053352719387), #c(0.408951651286696, 0.33656220322887, 0.726202391505946),
Ia = c(2.90602921191748, 13.3024309367662, 14.3707995986407),
rbarD = c(0.0723700801886747, 0.281642324983496, 0.270617053778004),
File = structure(c(1L, 1L, 1L), class = "factor", .Label = "rootrot.csv")),
File = rep("rootrot.csv", 3)),
.Names = c("Pop", "N", "MLG", "eMLG", "SE", "H", "G", "lambda", "E.5", "Hexp", "Ia", "rbarD", "File"),
row.names = c(NA, -3L),
class = c("popprtable", "data.frame"))

pc_comparison <- structure(list(Pop = structure(1:5, .Label = c("1", "2", "3",
"4", "Total"), class = "factor"),
pc_comparison <- structure(list(Pop = c("1", "2", "3", "4", "Total"),
N = c(13, 13, 12, 12, 50),
MLG = c(10, 12, 11, 9, 26),
eMLG = c(9.46153846153846, 11.1538461538462, 11, 9, 9.93701353621932),
Expand All @@ -41,7 +38,7 @@ pc_comparison <- structure(list(Pop = structure(1:5, .Label = c("1", "2", "3",
0.559212121212121), #c(0.849679487179487, 0.83629191321499, 0.714756944444444, 0.750347222222222, 0.78384),
Ia = c(2.1580763424628, 1.87492360969648, 1.15572679509632, 1.157153633392, 1.93513179817012),
rbarD = c(0.243225877705591, 0.212786561587854, 0.132460530412697, 0.13328661732193, 0.217470007471919),
File = structure(c(1L, 1L, 1L, 1L, 1L), class = "factor", .Label = "partial_clone.dat")),
File = rep("partial_clone.dat", 5)),
.Names = c("Pop", "N", "MLG", "eMLG", "SE", "H", "G", "lambda", "E.5", "Hexp", "Ia", "rbarD", "File"),
row.names = c(NA, -5L),
class = c("popprtable", "data.frame"))
Expand Down Expand Up @@ -145,4 +142,4 @@ test_that("poppr without sampling works on data without populations", {
out <- poppr(partial_clone, sample = 9, quiet = TRUE)
expect_is(out, "data.frame")
expect_equal(nrow(out), 1L)
})
})

0 comments on commit 6f26ecc

Please sign in to comment.