0

I want to create an R package, but I'm completely new in this topic, and even though I've already checked some excellent resources like Hadley Wickham's R packages book, I've a couple of questions that I'd like to clarify:

  1. Do I need to import the stats package to make use of the lm function?
  2. How can I make use of the piping operator %>% in the magrittr package since I can not write library(magrittr)?
  3. If I created a function that is for utility purposes but it shouldn't be available to the end user, how can I hide it?

Any help is greatly appreciated!

jroberayalas
  • 969
  • 7
  • 23

1 Answers1

3

Do I need to import the stats package to make use of the lm function?

No. It's loaded automatically. You only need to import for packages not loaded when R boots (like lattice)

How can I make use of the piping operator %>% in the magrittr package since I can not write library(magrittr)?

I'd import it as Hadley does HERE in dplyr:

#' @importFrom magrittr %>%
#' @name %>%
#' @export
#' @rdname chain
#' @usage lhs \%>\% rhs
NULL

If you're not using roxygen2 to document I'd really recommend it, but if you're reading Hadley's tutorial you probably will go that route.

Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519
  • Thanks a lot @tyler-rinker for your reply! One last question: if I created a function that is for utility purposes but it shouldn't be available to the end user, how can I hide it? – jroberayalas Apr 01 '15 at 15:55
  • It is hidden automatically. Only functions that you explicitly **export** are directly visible to the user. Using `roxygen`, you do this using ´@export`. – Eike P. Apr 01 '15 at 15:59
  • 1
    Your HERE link is dead, btw. Maybe you want this one https://github.com/hadley/dplyr/blob/bd372a4d625b225a40354a9a091b9185c7736dae/R/utils.r – Frank Apr 05 '16 at 16:47