File: weighted_mean.Rd

package info (click to toggle)
r-cran-datawizard 1.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,300 kB
  • sloc: sh: 13; makefile: 2
file content (56 lines) | stat: -rw-r--r-- 1,407 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/weighted_mean_median_sd_mad.R
\name{weighted_mean}
\alias{weighted_mean}
\alias{weighted_median}
\alias{weighted_sd}
\alias{weighted_mad}
\title{Weighted Mean, Median, SD, and MAD}
\usage{
weighted_mean(x, weights = NULL, remove_na = TRUE, verbose = TRUE, ...)

weighted_median(x, weights = NULL, remove_na = TRUE, verbose = TRUE, ...)

weighted_sd(x, weights = NULL, remove_na = TRUE, verbose = TRUE, ...)

weighted_mad(
  x,
  weights = NULL,
  constant = 1.4826,
  remove_na = TRUE,
  verbose = TRUE,
  ...
)
}
\arguments{
\item{x}{an object containing the values whose weighted mean is to be
    computed.}

\item{weights}{A numerical vector of weights the same length as \code{x} giving
the weights to use for elements of \code{x}. If \code{weights = NULL}, \code{x} is passed
to the non-weighted function.}

\item{remove_na}{Logical, if \code{TRUE} (default), removes missing (\code{NA}) and infinite
values from \code{x} and \code{weights}.}

\item{verbose}{Show warning when \code{weights} are negative?}

\item{...}{arguments to be passed to or from methods.}

\item{constant}{scale factor.}
}
\description{
Weighted Mean, Median, SD, and MAD
}
\examples{
## GPA from Siegel 1994
x <- c(3.7, 3.3, 3.5, 2.8)
wt <- c(5, 5, 4, 1) / 15

weighted_mean(x, wt)
weighted_median(x, wt)

weighted_sd(x, wt)
weighted_mad(x, wt)

}