View source: R/helper.functions.r
wtd.cor | R Documentation |
Given two numeric variables, wtd.cor reports correlation coefficient, works with sampling weights.
The wtd.cor
function is imported from the weights package. See wtd.cor
documentation for details.
wtd.cor(x1, x2, w = NULL, data, digits = 3, stats = FALSE, ...)
x1 |
A variable (must be numeric), should be in dataset$var form unless dataset specified in optional data argument. |
x2 |
Another variable, different than x1 (must be numeric), should be in dataset$var form unless dataset specified in optional data argument. |
w |
(Optional) Sampling weights of variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument. |
data |
(Optional) Name of dataset that contains x (and w) variable. |
digits |
(Optional) Number of decimal places reported in result (defaults: 3). |
stats |
(Optional) Do you want inferential statistics for correlation coefficient? (default: FALSE) |
... |
(Optional) Additional arguments passed to weights::wtd.cor function. |
Returns the coefficient of correlation between x1 and x2 variables, a numeric value.
library(RCPA3)
wtd.cor(x1=nes$ft.rep, x2=nes$ft.pence.pre, w=nes$wt)
wtd.cor(x1=ft.dem, x2=ft.harris.pre, w=wt, data=nes)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.