shift.rownames: Shift the first column of a dataframe to rownames() if...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/reader.R

Description

Checks whether the first column looks like IDs, and if so will. remove the column, and move these values to rownames.

Usage

1
shift.rownames(dataf, override = FALSE, warn = FALSE)

Arguments

dataf

data.frame to run the conversion on

override

assume col 1 is rownames, regardless of numeric() test

warn

whether to display warnings if assumptions aren't met

Value

returns vectors of strings of char, lengths X

Author(s)

Nicholas Cooper nick.cooper@cimr.cam.ac.uk

See Also

reader

Examples

1
2
3
4
5
6
7
df1 <- data.frame(ID=paste("ID",101:110,sep=""),
                   scores=sample(70,10,TRUE)+30,age=sample(7,10,TRUE)+11)
shift.rownames(df1)
df2 <- data.frame(ID=paste(101:110),
                   scores=sample(70,10,TRUE)+30,age=sample(7,10,TRUE)+11)
shift.rownames(df2) # first col are all numbers, so no convert
shift.rownames(df2,override=TRUE) # override forces conversion

Example output

Loading required package: NCmisc

Attaching package:readerThe following objects are masked frompackage:NCmisc:

    cat.path, get.ext, rmv.ext

      scores age
ID101     45  13
ID102     60  16
ID103     38  12
ID104     63  18
ID105     39  12
ID106     35  13
ID107     61  14
ID108     56  16
ID109     35  14
ID110     74  14
    scores age
101     44  17
102     76  13
103     78  15
104     33  13
105     83  17
106     51  15
107     74  14
108     84  16
109     43  14
110     57  15
    scores age
101     44  17
102     76  13
103     78  15
104     33  13
105     83  17
106     51  15
107     74  14
108     84  16
109     43  14
110     57  15

reader documentation built on May 2, 2019, 9:27 a.m.