insertMissing: Insert Missing Data

View source: R/insertMissing.R

insertMissingR Documentation

Insert Missing Data

Description

Inserts rows of missing values into a data frame for gaps in a sequence.

Usage

insertMissing(x, col, fill = FALSE)

Arguments

x

the data frame.

col

the name of the column that defines the sequence.

fill

logical (TRUE or FALSE), fill with many rows of data to match the sequence? If FALSE, insert only a single row. See Note.

Value

A data frame like x, but with rows of missing values where there is a break in the sequence in column col.

Note

Setting fill to TRUE is useful for setting up datasets for fillMissing if there are gaps in the retrieved data. Setting fill to FALSE, the default, is useful for creating a break in the sequence for plotting the data.

See Also

fillMissing, screenData

Examples

## Not run: 
library(smwrData)
data(Q05078470)
# Plot the original data
with(Q05078470[100:120, ], plot(DATES, FLOW, type="l"))
# Remove 3 rows from the data set
Q05078470 <- Q05078470[-(109:111), ]
# Plot the data--line drawn through the missing record
with(Q05078470[100:117, ], lines(DATES, FLOW, col="green"))
# Insert a missing record
Q05078470 <- insertMissing(Q05078470, "DATES")
# Now plot to show gap in line
with(Q05078470[100:118, ], lines(DATES, FLOW, col="blue"))

## End(Not run)

USGS-R/smwrBase documentation built on Oct. 18, 2022, 9:55 a.m.