diff --git a/.gitignore b/.gitignore index 16add95a..21fd6a3f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,5 @@ .Rdata .httr-oauth .DS_Store -docs +#docs inst/doc diff --git a/docs/404.html b/docs/404.html new file mode 100644 index 00000000..130e0823 --- /dev/null +++ b/docs/404.html @@ -0,0 +1,105 @@ + + +
+ + + + +YEAR: 2022 +COPYRIGHT HOLDER: Steven Paul Sandeson II, MPH ++ +
Copyright (c) 2022 Steven Paul Sandeson II, MPH
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+getting-started.Rmd
+library(TidyDensity)
The goal of TidyDensity is to …
+You can install the development version of TidyDensity from GitHub with:
+
+# install.packages("devtools")
+devtools::install_github("spsanderson/TidyDensity")
This is a basic example which shows you how to solve a common problem:
+
+library(TidyDensity)
+## basic example code
What is special about using README.Rmd
instead of just README.md
? You can include R chunks like so:
+summary(cars)
+#> speed dist
+#> Min. : 4.0 Min. : 2.00
+#> 1st Qu.:12.0 1st Qu.: 26.00
+#> Median :15.0 Median : 36.00
+#> Mean :15.4 Mean : 42.98
+#> 3rd Qu.:19.0 3rd Qu.: 56.00
+#> Max. :25.0 Max. :120.00
You’ll still need to render README.Rmd
regularly, to keep README.md
up-to-date. devtools::build_readme()
is handy for this. You could also use GitHub Actions to re-render README.Rmd
every time you push. An example workflow can be found here: https://github.com/r-lib/actions/tree/v1/examples.
You can also embed plots, for example:
+In that case, don’t forget to commit and push the resulting figure files, so they display on GitHub and CRAN.
+pipe.Rd
See magrittr::%>%
for details.
lhs %>% rhs
A value or the magrittr placeholder.
A function call using the magrittr semantics.
The result of calling rhs(lhs)
.
tidyeval.Rd
This page lists the tidy eval tools reexported in this package from +rlang. To learn about using tidy eval in scripts and packages at a +high level, see the dplyr programming vignette +and the ggplot2 in packages vignette. +The Metaprogramming section of Advanced R may also be useful for a deeper dive.
The tidy eval operators {{
, !!
, and !!!
are syntactic
+constructs which are specially interpreted by tidy eval functions.
+You will mostly need {{
, as !!
and !!!
are more advanced
+operators which you should not have to use in simple cases.
The curly-curly operator {{
allows you to tunnel data-variables
+passed from function arguments inside other tidy eval functions.
+{{
is designed for individual arguments. To pass multiple
+arguments contained in dots, use ...
in the normal way.
enquo()
and enquos()
delay the execution of one or several
+function arguments. The former returns a single expression, the
+latter returns a list of expressions. Once defused, expressions
+will no longer evaluate on their own. They must be injected back
+into an evaluation context with !!
(for a single expression) and
+!!!
(for a list of expressions).
my_function <- function(data, var, ...) {
+ # Defuse
+ var <- enquo(var)
+ dots <- enquos(...)
+
+ # Inject
+ data %>%
+ group_by(!!!dots) %>%
+ summarise(mean = mean(!!var))
+}
In this simple case, the code is equivalent to the usage of {{
+and ...
above. Defusing with enquo()
or enquos()
is only
+needed in more complex cases, for instance if you need to inspect
+or modify the expressions in some way.
The .data
pronoun is an object that represents the current
+slice of data. If you have a variable name in a string, use the
+.data
pronoun to subset that variable with [[
.
Another tidy eval operator is :=
. It makes it possible to use
+glue and curly-curly syntax on the LHS of =
. For technical
+reasons, the R language doesn't support complex expressions on
+the left of =
, so we use :=
as a workaround.
Many tidy eval functions like dplyr::mutate()
or
+dplyr::summarise()
give an automatic name to unnamed inputs. If
+you need to create the same sort of automatic names by yourself,
+use as_label()
. For instance, the glue-tunnelling syntax above
+can be reproduced manually with:
my_function <- function(data, var, suffix = "foo") {
+ var <- enquo(var)
+ prefix <- as_label(var)
+ data %>%
+ summarise("{prefix}_mean_{suffix}" := mean(!!var))
+}
Expressions defused with enquo()
(or tunnelled with {{
) need
+not be simple column names, they can be arbitrarily complex.
+as_label()
handles those cases gracefully. If your code assumes
+a simple column name, use as_name()
instead. This is safer
+because it throws an error if the input is not a name as expected.