Description Usage Arguments Details Value Examples

Function used to compute different kind of mean in variables.

1 |

`x` |
Numeric. A vector of the data set. |

`meth` |
Character. To compute the arithmetic (meth="a"), harmonic ("h"), geometric ("g") or weighted ("w") mean. Only for weighted mean option, an additional column including the weight of values is required. |

`narm` |
Logical. Optional argument used to compute the mean removing NA values. |

`dec` |
Numeric. A value to define the number of decimals in the returns. |

This function shows the mean as a numerical value from the data set. For the case of weighted mean, an additional column must be included in the dataset containing the assigned weigths of each value. The weighted mean is computed taking into account the total percentage of weights, that is, for cases that the sumed of wights is 100% or different (i.e. 90%, 120%, etc).

This function returns a numerical value representing the mean depending on used method.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ```
#Example 1
data1=c(7,6,NA,8,NA)
meanWH(x=data1,meth="a",narm=TRUE)
#Example 2
data2=rnorm(10,50,3)
meanWH(x=data2,meth="a",dec=2)
#Example 3
data3=rnorm(100,50,11)
meanWH(x=data3,meth="g")
#Example 4
data4=rnorm(10,20,4)
meanWH(data4,meth="h")
#Example 5 (total weight is closed to 100%)
df1=data.frame(value=c(9,8,7,8),weight=c(0.5,0.2,0.2,0.1))
meanWH(df1,meth="w")
#Example 6 (total weight is not closed 100%)
df2=data.frame(value=c(9,8,7,8),weight=c(0.5,0.2,0.2,0.2))
meanWH(df2,meth="w")
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.