0

I am trying to find the best way to use this pedigree class without using library pedigreemm first.

p1 <- new("pedigree", sire = as.integer(c(NA,NA,1, 1,4,5)), dam = as.integer(c(NA,NA,2,NA,3,2)), label = as.character(1:6)) 

Error in getClass(Class, where = topenv(parent.frame())) :
“pedigree” is not a defined class

To be clear, I am trying to do something like base::mean(). However, as the new() function do not belong to the pedigreemm package seems to be not that straightforward. Thus, I can't just do pedigreemm::new(). It is important to highlight that the code works just fine if I load the pedigreemm package first, but I need a way to run without loading it first. Any ideas?

6
  • Might not be possible... can you explain why you need to do this? We may be able to help you find a better solution to the root problem. Commented Feb 20, 2019 at 16:56
  • It is a function inside a package. Thus, package::function is always preferred. Commented Feb 20, 2019 at 16:58
  • Have you tried to add @importClassesFrom pedigreemm pedigree if using roxygen2? If the class is defined in another package, then I think the only option available is to import the class. Commented Feb 20, 2019 at 17:22
  • 2
    Also, I don't think using package::function is always prefered. As an example: if you intend to use ggplot2 functions in a package, then calling ggplot2::function will make the code long and hard to read as you end up using many functions together (i.e. aes, ggplot, geom_*, scale_*, etc). While you could import those functions and have a shorter and more legible code. Commented Feb 20, 2019 at 17:28
  • @Freguglia, could you give an example on how to wisely import functions? Commented Feb 20, 2019 at 21:31

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.