rate_DF {disprose}R Documentation

Rate variables

Description

Count data frame's row rate according to several variables

Usage

rate_DF(
  data,
  rate.var,
  weights,
  return = "add",
  as.percent = FALSE,
  percent.var,
  digits = 2
)

Arguments

data

data frame with rated variables

rate.var

character; vector of data frame column names with numeric variables of range (0-1) that should be used for rating

weights

numeric; vector of variables' weights (their sum must be 1)

return

character; return object; possible values are: "vector" (return a vector of rate values), "add" (add rated values as the latter column in data frame)

as.percent

logical; if some rated variables are percentages

percent.var

character; vector of data frame column names with rated variables that are percentages

digits

integer; number of decimal places to round the rate value

Details

This function counts rate as rate = var1*weight1 + var2*weight2 + var3*weight3 +... etc. All variables must be in range (0-1) and sum of weights must be 1. If you use percentages as rating variable, use as.percent = TRUE. Those variables would be divided by 100 before rating and then would be multiplicated by 100 after rating.

rate.var and percent.var must be exact column names as in data frame.

Value

Vector or data frame with rate values.

Author(s)

Elena N. Filatova

Examples

data <- data.frame (N = 1:5, percent = c(12, 15, 18, 20, 94), number = c(0.1, 0.5, 0.6, 0.8 ,0.9))
rate_DF (data = data, rate.var = c("percent", "number"), weights = c(0.4, 0.6), return = "add",
                             as.percent = TRUE, percent.var = "percent")


[Package disprose version 0.1.6 Index]