Last data update: 2014.03.03

R: FACTOR UNITILITIES
factor2numericR Documentation

FACTOR UNITILITIES

Description

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

Usage

factor2numeric(x)
relevels(x, refs)

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

## 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"))

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(RTCA)
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, xtabs

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

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colnames, 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, rownames, sapply, setdiff, sort, table, tapply, union,
    unique, unsplit

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
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/RTCA/factor2numeric.Rd_%03d_medium.png", width=480, height=480)
> ### Name: factor2numeric
> ### Title: FACTOR UNITILITIES
> ### Aliases: factor2numeric relevels
> ### Keywords: misc
> 
> ### ** Examples
> 
> ## factor2numeric
> numFac <- factor(c(3.5, 2.5, 2.5,3.5, 1))
> numFac
[1] 3.5 2.5 2.5 3.5 1  
Levels: 1 2.5 3.5
> levels(numFac)
[1] "1"   "2.5" "3.5"
> 
> factor2numeric(numFac)
[1] 3.5 2.5 2.5 3.5 1.0
> class(factor2numeric(numFac))
[1] "numeric"
> 
> ## relevels
> relevels(numFac, c("3.5", "1", "2.5"))
[1] 3.5 2.5 2.5 3.5 1  
Levels: 3.5 1 2.5
> relevels(numFac, c("3.5", "2.5"))
[1] 3.5 2.5 2.5 3.5 1  
Levels: 3.5 2.5 1
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>