This function removes any rows in which an 'NA' or an 'Inf' entry is found. The function is also able to remove records with 'Inf' entries, distinguishing it from the popular 'na.omit()' function in R.
remove_rows_n(traj, id_field=TRUE, remove=1)
traj | [data.frame (numeric)]: longitudinal data. Each row represents an individual trajectory (of observations). The columns show the observations at consecutive time points. |
---|---|
id_field | [numeric or character] Whether the first column
of the |
remove | [integer] Type of missing entries to remove.
|
A matrix with complete observations
Given a matrix (or a dataframe) containing an 'NA' or an 'Inf' entry, the function returns only rows with complete observations.
#> [1] "Message: 6 row(s) containing 'NA' or 'Inf' entries removed!"#> $totalRowsRemoved #> [1] 6 #> #> $CleanData #> location_ids X2001 X2002 X2003 X2004 X2005 X2006 X2007 X2008 X2009 #> 1 E01012628 3 0 1 2 1 0 1 4 0 #> 3 E01004803 4 3 0 10 2 3 6 6 8 #> 6 E01004808 8 5 8 4 1 5 6 1 1 #> 10 E01004806 25 12 14 15 18 13 21 27 17 #>