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

Share:

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