Comments (2)
For roxygen2
documentation, we can adopt the following convention,
mainly from Hadley Wickham's R packages section,
but with some changes. Some guidelines specific to our package are:
- The first line is the high level title. It should not end in a period
.
see here - There should be a 1 line gap between all main fields e.g. between
@param
and@return
. This is a little unconventional, but I feel good practice, see here. - The first line of the description should begin with
code{function_name}
, see here. - For the
@examples
section we should always use set.seed for reproducibility, see here. - Any block that begins with a keyword e.g.
@details
,@param
,@return
etc, and is split over multiple lines, should have the second and onward lines indented by 2 spaces, see here. - We should use indented code blocks in our
@examples
section, see here - Each specification of @param should start as "A numeric/character/etc scalar/vector/etc; ..." or "A numeric/character/etc scalar/vector/etc indicating ...."
from maars.
For the ggplot2
wrapper, we can do something simple like this and put in our utils-common.R
:
#' Set the custom \code{\link[ggplot2]{theme}} for our plots
#'
#' \code{set_ggplot2_theme} is a wrapper to set a standard custom
#' \code{\link[ggplot2]{theme}} for all of our output plots. It contains
#' only the necessary parameters we require to change in the
#' \code{\link[ggplot2]{theme}} function, and takes the remaining arguments
#' as the default values.
#'
#' @param ggplot_obj A \code{\link[ggplot2]{ggplot2}} object
#' @param axis_text_size A positive integer to define the the size of the x and
#' y axis text in our \code{\link[ggplot2]{ggplot2}} object
#' @param axis_title_size A positive integer to define the the size of the x and
#' y axis text in our \code{\link[ggplot2]{ggplot2}} object
#' @param strip_text_x_size A positive integer to define the the size of the x and
#' y axis text in our \code{\link[ggplot2]{ggplot2}} object
#' @param legend_text_size A positive integer to define the the size of the x and
#' y axis text in our \code{\link[ggplot2]{ggplot2}} object
#' @param legend_title_size A positive integer to define the the size of the x and
#' y axis text in our \code{\link[ggplot2]{ggplot2}} object
#' @param legend_position A character value the position of legends
#' ("none", "left", "right", "bottom", "top", or two-element numeric vector)
#'
#' @return
#' @export
#'
#' @examples
set_ggplot2_theme <- function(ggplot_obj,
axis_text_size = 17,
axis_title_size = 17,
strip_text_x_size = 17,
legend_text_size = 17,
legend_title_size = 17,
legend_position = "bottom") {
out <- ggplot_obj +
ggplot2::theme_bw() +
ggplot2::theme(
axis.text = ggplot2::element_text(size = axis_text_size),
axis.title = ggplot2::element_text(size = axis_title_size),
strip.text.x = ggplot2::element_text(size = strip_text_x_size),
legend.text = ggplot2::element_text(size = legend_text_size),
legend.title = ggplot2::element_text(size = legend_title_size),
legend.position = legend_position
)
return(out)
}
We could then call on this function as follows:
library(ggplot2)
p1 <- ggplot2::ggplot(mtcars, aes(x = wt, y = mpg, size = disp)) +
ggplot2::geom_point()
# Set the theme for a `ggplot2` object with the default options
out <- p1 %>% maars::set_ggplot2_theme(ggplot_obj = .)
NOTE: This is now created in utils-common.R
. There is also a test-utils-common.R
file.
from maars.
Related Issues (20)
- FT: speed up the bootstrap functions HOT 1
- FT: Design the maars_lm class
- FT: Function to generate assumptions
- FT: Create the comp_var summary function HOT 1
- DOC: Update LICENCE to be GPL-2 and GPL-3 per JSS review requirements.
- FT: write tidy method for maars_lm
- ENH: miscellaneous HOT 1
- FT: Subsampling
- FT: Plots for mss_var HOT 1
- FT: Function for confidence intervals
- FT: Updates in preparation for upcoming demo
- FT: Future Feature requests (AK) HOT 1
- FT: Post-demo fix issues
- FT: Fix `get_confint()` and `confint()` and assertion checking
- FT: Miscellaneous
- FT: Fix and consolidate code in `maars-lm` and `ols-summary`
- FT: Modify Assertion checking + Assumptions prototype
- FT: Write vignettes HOT 1
- FT: (pseudo) t-test for coefficients HOT 1
- Emoji characters on Windows HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from maars.