translate {dembase} | R Documentation

## Translate between classifications.

### Description

Translate between classifications, based on a concordance.

### Usage

    translate(object, concordance, to = NULL, ...)

    ## S4 method for signature 'ANY,ManyToOne,missing'
    translate(object, concordance)

    ## S4 method for signature 'ANY,ManyToOne,ANY'
    translate(object, concordance, to)

    ## S4 method for signature 'ANY,OneToOne,ANY'
    translate(object, concordance, to = NULL)

    ## S4 method for signature 'ANY,OneToOne,'NULL''
    translate(object, concordance, to = NULL)

    ## S4 method for signature 'ANY,OneToOne,missing'
    translate(object, concordance)

    ## S4 method for signature 'ANY,data.frame,ANY'
    translate(object, concordance, to = NULL, ...)

    ## S4 method for signature 'ANY,matrix,ANY'
    translate(object, concordance, to = NULL, ...)

### Arguments

`object` | A character vector.
`concordance` | An object of class `Concordance`.
`to` | Name of classification within `concordance` that codes from `object` should be translated to.
`...` | Not currently used.

### Details

If `concordance` is `ManyToOne`, then `object` must be the 'many' part, and argument `to` is not required. If `concordance` is `OneToOne`, and `to` is not supplied, `translate` guess, based on the values in `object`.

### Value

A character vector, the same length as `object`.

### Examples

    conc <- data.frame(code = 1:3,
                       descriptor = c("North Island", "South Island",
                                       "Stewart Island"))
    conc <- Concordance(conc)
    conc
    translate(c("1", "3", "1", "2"),
              concordance = conc)
    translate(c("Stewart Island", "North Island"),
              concordance = conc)

    codes(conc, classification = "code")
    codes(conc, classification = "descriptor")

    conc <- data.frame(sex1 = c("girl", "boy", "woman", "man"),
                       sex2 = c("female", "male"))
    conc <- Concordance(conc)
    conc
    translate(c("man", "girl"), concordance = conc)
    ## Not run:
    translate(c("female", "male"), concordance = conc)

    ## End(Not run)

[Package dembase version 0.0.0.119 Index]