transpose: Function to transpose a data frame or a file

Description Usage Arguments Details Value Examples

View source: R/PediHaplotyper.r

Description

This is a function to help in formatting the input and/or output data of PediHaplotyper. It transposes a data frame or file, with some differences from t().

Usage

1
2
transpose(source, target = "", sep = "", skip = 0, 
  na.strings = "NA", sep.out = "\t", na.out = "", ...)

Arguments

source

Either a data frame or a file name: the data to be transposed. If a file name, the file should be readable by read.table() with header=TRUE; all other parameters for read.table have the default values of read.table but can be specified.

target

Ignored if source is a data frame, else the name of the transposed file

sep

Ignored if source is a data frame, else the separator (passed to read.table)

skip

Ignored if source is a data frame, else the number of lines to skip (passed to read.table)

na.strings

Ignored if source is a data frame, else the strings used to represent NA values (passed to read.table)

sep.out

Ignored if source is a data frame, else the separator to be used in the target file

na.out

Ignored if source is a data frame, else the representation of NA values to be used in the target file

...

Ignored if source is a data frame, else further parameters to be passed to read.table

Details

This function transposes a data frame such that the original column names go to the first column (which is called "name") and the original contents of the first column become the column names. Row names are ignored. If source is a file name the file is read using read.table; it must contain a header line, but in contrast to read.table the headers are not modified if they are not valid identifiers or if duplicate headers occur. The column names of the transposed data frame may be invalid as identifiers and/or duplicate column names may occur, depending on the contents of the first column of the source data frame. Invalid column names do not affect any of the PediHaplotyper functions.

Value

The return value is always the transposed data frame. If source and target are file names also the target file is created, overwriting any previous file.

Examples

1
2
3
data(mrkdat) # a data frame with data for two markers and two individuals
mrkdat
transpose(mrkdat)

PBR/PediHaplotyper documentation built on Feb. 3, 2021, 12:03 a.m.