Skip to content

Commit 6d8c996

Browse files
author
agaye
committed
'dataframeDS' amended to enable the option of genrating a table without missing values.
1 parent 3238776 commit 6d8c996

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

‎R/dataframeDS.R‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
#' are checked to ensure that they are syntactically valid variable names and are not duplicated.
1010
#' @param clnames a list of charcaters, the column names of the output data frame.
1111
#' @param strAsFactors logical, tells if character vectors should be converted to factors?
12+
#' @param completeCases a character that tells if only complete cases should be included or not.
1213
#' @return a dataframe
1314
#' @author Gaye, A.
1415
#' @export
1516
#'
16-
dataframeDS <- function (vectors=NULL,r.names=NULL,ch.rows=FALSE,ch.names=TRUE,clnames=NULL,strAsFactors=TRUE) {
17+
dataframeDS <- function (vectors=NULL,r.names=NULL,ch.rows=FALSE,ch.names=TRUE,clnames=NULL,strAsFactors=TRUE,completeCases=FALSE) {
1718
# this filter sets the minimum number of observations that are allowed
1819
nfilter <- setFilterDS()
1920

@@ -24,9 +25,14 @@ dataframeDS <- function (vectors=NULL,r.names=NULL,ch.rows=FALSE,ch.names=TRUE,c
2425
r.names <- unlist(r.names)
2526
}
2627

27-
dt <- data.frame(vectors, row.names=r.names, check.rows=ch.rows, check.names=ch.names,
28+
dtemp <- data.frame(vectors, row.names=r.names, check.rows=ch.rows, check.names=ch.names,
2829
stringsAsFactors=strAsFactors)
29-
colnames(dt) <- unlist(clnames)
30+
colnames(dtemp) <- unlist(clnames)
31+
if(completeCases){
32+
dt <- dtemp[complete.cases(dtemp),]
33+
}else{
34+
dt <- dtemp
35+
}
3036

3137
# check if the resulting dataframe is valid and output accordingly
3238
if(dim(dt)[1] < nfilter){

‎man/dataframeDS.Rd‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
\title{Creates a data frame}
44
\usage{
55
dataframeDS(vectors = NULL, r.names = NULL, ch.rows = FALSE,
6-
ch.names = TRUE, clnames = NULL, strAsFactors = TRUE)
6+
ch.names = TRUE, clnames = NULL, strAsFactors = TRUE,
7+
completeCases = FALSE)
78
}
89
\arguments{
910
\item{vectors}{a list which contains the vectors to
@@ -25,6 +26,9 @@ dataframeDS(vectors = NULL, r.names = NULL, ch.rows = FALSE,
2526

2627
\item{strAsFactors}{logical, tells if character vectors
2728
should be converted to factors?}
29+
30+
\item{completeCases}{a character that tells if only
31+
complete cases should be included or not.}
2832
}
2933
\value{
3034
a dataframe

0 commit comments

Comments
 (0)