rSCA.missing: Checking Missing Values for Modeling Data Sets

Description Usage Arguments Value Author(s) Examples

View source: R/rSCA.missing.r

Description

This function helps check if there are missing values in the modeling data sets. It prints out general statistics for missing values and their specific locations in the data matrix. It returns TRUE/FALSE to indicate whether the data file passes the missing check.

Usage

1
2
	rSCA.missing(file, row.names = FALSE, col.names = FALSE, 
        missing.flag = "NA", type = ".txt")

Arguments

file

a string to specify the full filename of the data file, only supports files in *.txt or *.csv.

row.names

a logical value to specify if the data file contains row names or not. Default value is FALSE.

col.names

a logical value to specify if the data file contains column names or not. Default value is FALSE.

missing.flag

a string to specify the missing flag used in the data file. Default value is "NA".

type

a string to specify the type of data file. Default value is ".txt".

Value

Return a logical value to indicate whether the data file contains missing value(s).

Author(s)

Xiuquan Wang <xiuquan.wang@gmail.com>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
## Load rSCA package
library(rSCA)

## Case 1: without column name and row name, using NA as missing flag
data <- c("5 7 9 10\r",
          "12 3 4 5\r",
          "1 NA NA 3\r",
          "2 NA 13 23\r",
          "0 12 1 8\r",
          "NA 9 0 1\r")
datafile <- tempfile()
writeLines(data, datafile)
bPass = rSCA.missing(file = datafile)

## Remove temporary data files
unlink(datafile)


## Case 2: with column name and row name, using -99 as missing flag
data <- c("Year V1 V2 V3 V4\r",
          "2010 5 7 9 10\r",
          "2012 12 3 4 5\r",
          "2013 1 -99 -99 3\r",
          "2014 2 -99 13 23\r",
          "2015 0 12 1 8\r",
          "2016 -99 9 0 1\r")
datafile <- tempfile()
writeLines(data, datafile)
bPass = rSCA.missing(file = datafile, col.names = TRUE, 
            row.names = TRUE, missing.flag = "-99")

## Remove temporary data files
unlink(datafile)

## Case 3: with column name and row name, using NA as missing flag,
##         stored in comma-separated value (CSV) format.
data <- c("Year,V1,V2,V3,V4\r",
          "2010,5,7,9,10\r",
          "2012,12,3,4,5\r",
          "2013,1,NA,NA,3\r",
          "2014,2,NA,13,23\r",
          "2015,0,12,1,8\r",
          "2016,NA,9,0,1\r")
datafile <- tempfile()
writeLines(data, datafile)
bPass = rSCA.missing(file = datafile, col.names = TRUE, 
            row.names = TRUE, missing.flag = "NA", type = ".csv")

## Remove temporary data files
unlink(datafile)

rSCA documentation built on March 13, 2020, 2:15 a.m.

Related to rSCA.missing in rSCA...