Last data update: 2014.03.03

R: Observed rating frequencies
rating.probR Documentation

Observed rating frequencies

Description

Computes observed rating frequencies per level of a factor, in various formats.

Usage

rating.prob(x, g, type = c("prob", "cumprob", "class"))

Arguments

x

ordered factor (ratings).

g

factor giving groups to be compared.

type

type of output to be returned: "prob" (default) gives frequency of each rating, "cumprob" gives cumulative frequencies (Fi is frequence of ratings <= i) and "class" gives the most frequent rating.

Author(s)

Maxime Herv<c3><a9> <mx.herve@gmail.com>

Examples

require(ordinal)
data(wine)

# Frequencies
rating.prob(wine$rating,wine$contact:wine$temp)

# Cumulative frequencies
rating.prob(wine$rating,wine$contact:wine$temp,type="cumprob")

# Most frequent rating
rating.prob(wine$rating,wine$contact:wine$temp,type="class")

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(RVAideMemoire)
*** Package RVAideMemoire v 0.9-56 ***
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/RVAideMemoire/rating.prob.Rd_%03d_medium.png", width=480, height=480)
> ### Name: rating.prob
> ### Title: Observed rating frequencies
> ### Aliases: rating.prob
> 
> ### ** Examples
> 
> require(ordinal)
Loading required package: ordinal
> data(wine)
> 
> # Frequencies
> rating.prob(wine$rating,wine$contact:wine$temp)
                  1          2         3         4         5
no:cold  0.22222222 0.50000000 0.2777778 0.0000000 0.0000000
no:warm  0.00000000 0.27777778 0.4444444 0.1666667 0.1111111
yes:cold 0.05555556 0.38888889 0.4444444 0.1111111 0.0000000
yes:warm 0.00000000 0.05555556 0.2777778 0.3888889 0.2777778
> 
> # Cumulative frequencies
> rating.prob(wine$rating,wine$contact:wine$temp,type="cumprob")
                  1          2         3         4 5
no:cold  0.22222222 0.72222222 1.0000000 1.0000000 1
no:warm  0.00000000 0.27777778 0.7222222 0.8888889 1
yes:cold 0.05555556 0.44444444 0.8888889 1.0000000 1
yes:warm 0.00000000 0.05555556 0.3333333 0.7222222 1
> 
> # Most frequent rating
> rating.prob(wine$rating,wine$contact:wine$temp,type="class")
 no:cold  no:warm yes:cold yes:warm 
     "2"      "3"      "3"      "4" 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>