factor2numeric: FACTOR UNITILITIES

Description Usage Arguments Details Value Author(s) Examples

View source: R/RTCAfunctions.R

Description

The functions implement easy interface to certain tasks of factor. See datails for explaination

Usage

1
2

Arguments

x

A vector of factor

refs

A vector of character, reference vector to give the orderof levels

Details

relevels re-arrange the order of levels by the given character refs. Alternatively user could use factor(...,levels=refs) to achieve a similar effect, however the relevels enables also partial list. The missing levels in refs will be ordered to the last.

factor2numeric converts factor of numerics into their numeric form.

Value

A vector of factor

Author(s)

Jitao David Zhang jitao_david.zhang@roche.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## factor2numeric
numFac <- factor(c(3.5, 2.5, 2.5,3.5, 1))
numFac
levels(numFac)

factor2numeric(numFac)
class(factor2numeric(numFac))

## relevels
relevels(numFac, c("3.5", "1", "2.5"))
relevels(numFac, c("3.5", "2.5"))

Example output

Loading required package: Biobase
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, sd, var, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, basename, cbind, colMeans, colSums, colnames,
    dirname, do.call, duplicated, eval, evalq, get, grep, grepl,
    intersect, is.unsorted, lapply, lengths, mapply, match, mget,
    order, paste, pmax, pmax.int, pmin, pmin.int, rank, rbind,
    rowMeans, rowSums, rownames, sapply, setdiff, sort, table, tapply,
    union, unique, unsplit, which, which.max, which.min

Welcome to Bioconductor

    Vignettes contain introductory material; view with
    'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.

Loading required package: RColorBrewer
Loading required package: gtools
[1] 3.5 2.5 2.5 3.5 1  
Levels: 1 2.5 3.5
[1] "1"   "2.5" "3.5"
[1] 3.5 2.5 2.5 3.5 1.0
[1] "numeric"
[1] 3.5 2.5 2.5 3.5 1  
Levels: 3.5 1 2.5
[1] 3.5 2.5 2.5 3.5 1  
Levels: 3.5 2.5 1

RTCA documentation built on Nov. 8, 2020, 7:52 p.m.