1
#' delete phenotypes from phdata
3
#' This function is used to delete certain
4
#' phenotypes from phenotypic part (phdata)
5
#' of an object of \code{\link{gwaa.data-class}}
7
#' @param data an object of \code{\link{gwaa.data-class}}
8
#' @param what which phenotypes (variables) to delete, expressed
9
#' as (vector of) names (character) or integer (column of
11
#' @param all if 'all'=TRUE and 'what' is misisng,
12
#' all phenotypes are deleted, and only the 'id'
15
#' @author Yurii Aulchenko
19
#' phdata(srdta)[1:5,]
20
#' srdta <- del.phdata(srdta,"qt1")
21
#' phdata(srdta)[1:5,]
22
#' srdta <- del.phdata(srdta,all=TRUE)
23
#' phdata(srdta)[1:5,]
27
del.phdata <- function(data,what,all=FALSE)
29
if (class(data) != "gwaa.data") stop("data should be of gwaa.data-class");
30
if (missing(what) && all) {
31
cat("Deleting all data but 'id' and 'sex'\n")
32
data@phdata <- data@phdata[,c("id","sex")]
35
if (missing(what)) stop("'what' could be missing only if 'all'=TRUE (delete all data)")
36
if (is.integer(what)) what <- names(data@phdata)[what]
38
if (any(what == "id")) stop("you can not delete 'id'")
39
if (any(what == "sex")) stop("you can not delete 'sex'")
41
nms <- names(data@phdata);
42
tokeep <- nms[!(nms %in% what)];
43
data@phdata <- data@phdata[,tokeep]
b'\\ No newline at end of file'