Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: L table is a data frame that has column names #4

Open
richelbilderbeek opened this issue Jan 7, 2019 · 1 comment
Open

Comments

@richelbilderbeek
Copy link
Contributor

Hi @xl0418, thanks for the dododo package!

In the work by me and @Giappo, I find a function like this:

bd_phylo_2_l_table <- function(phylo) {
  l_table <- dododo::phylo2L(phylo) # nolint
  colnames(l_table) <- c("birth_time", "parent", "id", "death_time")
  return(l_table)
}

All that function does, is convert the L table into a data frame and add column names.

I think this is superior over the current state of affairs, in which an L table is a matrix. Matrices only apply to data of the same type, where a species/parent ID and time of birth/death clearly have different units.

In effect, I suggest the following test to be added:

test_that("L table is a data frame that has column names", {

  phylogeny <- ape::read.tree(text = "((t1:1, t3:1):1, t2:2);")
  l_table <- phylo2L(phylogeny)
  expect_true(is.data.frame(l_table))
  col_names <- colnames(l_table)
  expected <- c("birth_time", "parent", "id", "death_time")
  expect_equal(col_names, expected)
})

I am rather sure @Giappo would volunteer to add this and the code to pass the test, as he was the original author of the first function.

Will you accept this suggestion yes/no?

@xl0418
Copy link
Owner

xl0418 commented Jan 7, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants