View source: R/insertMissing.R
| insertMissing | R Documentation |
Inserts rows of missing values into a data frame for gaps in a sequence.
insertMissing(x, col, fill = FALSE)
x |
the data frame. |
col |
the name of the column that defines the sequence. |
fill |
logical ( |
A data frame like x, but with rows of missing values where
there is a break in the sequence in column col.
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.
fillMissing, screenData
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.