fdata: format dataset

View source: R/basF.R

fdataR Documentation

format dataset

Description

fdata This function will format dataset for Varialbes to factors.

Usage

fdata(data, faS = NULL, FtN = FALSE, ped = FALSE)

Arguments

data

dataset.

faS

The column location of factor Variables.

FtN

Change factoric indexs to numeric indexs, default (F).

ped

Change factoric pedigree to numeric type, default (F).

Details

This function formats dataset Varialbes between factor and numeric type. When using for factor to numeric, faS should be a list of sites for characteric and numeric type factor respectively, i.e., faS=list(c(2:4),c(1,5:8)), with site 2:4 (character factors) and site c(1,5:8) (numeric factors), one of them can be 0.

Value

this returned a formated dataset.

Author(s)

Yuanzhen Lin <yzhlinscau@163.com>

References

Yuanzhen Lin. R & ASReml-R Statistics. China Forestry Publishing House. 2016 AFfR website:https://github.com/yzhlinscau/AFfR

See Also

See Also as read.file, read.example

Examples

library(AFEchidna)
names(mtcars)

mtcars1<-fdata(mtcars,faS=c(2,8,9))

data(sp,package='RSTAT2D')
sp1<-fdata(sp,faS=list(c(2:4),c(1,5:8)),FtN=TRUE)
str(sp1) # or head(sp1)
# list reformed levels
sp1$rf$Mum # or sp1$rf[[1]]

# only change numeric-factor to numeric index
sp1a<-fdata(sp,faS=list(0,c(1,5:8)),FtN=TRUE)
# only change characteric-factor to numeric index
sp1b<-fdata(sp,faS=list(c(2:4),0),FtN=TRUE)

sp2<-fdata(sp[,1:3],ped=TRUE)
sp3<-fdata(sp2,faS=1:3)


yzhlinscau/AAfun0s documentation built on April 18, 2023, 4:11 p.m.