rename.duplicate: Function to rename duplicated strings.

Description Usage Arguments Value Author(s) Examples

Description

This function renames duplicated strings by adding their number of occurrences at the end.

Usage

1
rename.duplicate(x, sep = "_", verbose = FALSE)

Arguments

x

vector of strings.

sep

a character to be the separator between the number added at the end and the string itself.

verbose

TRUE to print informative messages, FALSE otherwise.

Value

new.x

new strings (without duplicates).

duplicated.x

strings which were originally duplicated.

Author(s)

Benjamin Haibe-Kains

Examples

1
2
3
nn <- sample(letters[1:10], 30, replace=TRUE)
table(nn)
rename.duplicate(x=nn, verbose=TRUE)

Example output

Loading required package: survcomp
Loading required package: survival
Loading required package: prodlim
Loading required package: mclust
Package 'mclust' version 5.4.3
Type 'citation("mclust")' for citing this R package in publications.
Loading required package: limma
Loading required package: biomaRt
Loading required package: iC10
Loading required package: pamr
Loading required package: cluster
Loading required package: impute
Loading required package: iC10TrainingData
Loading required package: AIMS
Loading required package: e1071
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 object is masked from 'package:limma':

    plotMA

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")'.

nn
a b c d e f g h i j 
1 3 6 1 3 3 3 5 3 2 
20 duplicated names
$new.x
 [1] "f"   "a"   "b"   "c"   "i"   "h"   "f_2" "g"   "j"   "d"   "h_2" "h_3"
[13] "c_2" "f_3" "g_2" "c_3" "g_3" "b_2" "e"   "i_2" "e_2" "j_2" "b_3" "c_4"
[25] "c_5" "c_6" "e_3" "h_4" "h_5" "i_3"

$duplicated.x
 [1] "f" "h" "h" "c" "f" "g" "c" "g" "b" "i" "e" "j" "b" "c" "c" "c" "e" "h" "h"
[20] "i"

genefu documentation built on Jan. 28, 2021, 2:01 a.m.