[ESS] Best Practice for building R packages
Jeremie Juste
jerem|eju@te @end|ng |rom gm@||@com
Thu Oct 8 15:14:42 CEST 2020
Hello Kasper,
Thanks for sharing.
> Personally, I'm a dinosaur so I'm still editing Rd files myself. I must
> say, I'm not convinced about the merits of roxygen2.
I admire your discipline. For my part, I feel that I would not document my
functions properly unless I constrain myself to do it on the fly. For
that I have created a [1] snippet (from [2] yassnippet package). I admit
that here is still room for improvement.
[2] https://github.com/joaotavora/yasnippet
[1] -- function --
# -*- mode: snippet -*-
# name: function
# key: fn
# --
##' .. content for \description{$3} (no empty lines) ..
##'
##' .. content for \details{} ..
##' @title $1
##' @param $2
##' @return
##' @author Jeremie Juste
$1 <- function($2){
$0
}
So typing fn[tab] would expand the snippet and force me to write some
documentation.
I used to naively include the documentation in the function itself in
comments but that is not the R way of sharing code.
build..table <- function(obj){
### DD
## obj of class lm
### purpose
## extract coef name, coef, std and pval from estimation of lm
res <- data.table(summary(obj)$coefficients[,c(1,2,4)],keep.rownames=TRUE)
setnames(res,c("name","coef","std","pval"))
res
}
Best regards,
--
Jeremie Juste
More information about the ESS-help
mailing list