Learn R Programming

mtk (version 1.0)

setLevels-methods: The setLevels method

Description

Sets new levels to a discrete distribution.

Usage

setLevels(this, levels)

Arguments

this
an object of the class mtkDomain or mtkLevels.
levels
an object of the class mtkLevels or a list from which we can create an object of the class mtkLevels.

Value

Examples

Run this code

# Create a  new mtkLevels for a discrete distribution

	l <- mtkLevels(type='categorical', levels = c(1,2,3,4,5), weights=rep(0.2, 5))
# Change the levels'name to ('a','b','c','d','e')
	setLevels(l, c('a','b','c','d','e'))
	
# Create a  new domain with a discrete distribution
	d <- mtkDomain(distributionName="discrete", domainNominalValue=3, 
			distributionParameters = list(type='categorical',
		 	levels = c(1,2,3,4,5), weights=rep(0.2, 5)))
		 
# Create a  new mtkLevels for a discrete distribution and assign it to the domain

	l <- mtkLevels(type='categorical', levels = c('a','b','c','d','e'), weights=rep(0.2, 5))
	setLevels(d, l)

# Change the domain's levels to type='categorical', levels = c(5,4,3,2,1), weights=rep(0.2, 5)
	
	setLevels(d, levels=list(type='categorical', levels = c(5,4,3,2,1), weights=rep(0.2, 5)))

Run the code above in your browser using DataLab