adjacent_rownums | R Documentation |
Given .DF
, find the row numbers that contain the first instance
in col_name
of adjacent entries
,
this function finds the row number of the adjacent entries
.
adjacent_rownums(.DF, col_name, entries)
.DF |
the data frame in which to search for |
col_name |
the column of |
entries |
a vector of length 2 representing the consecutive entries in |
This function is helpful for finding boundaries between rows of a data frame in preparation for defining grouping variables.
an integer vector of length 2 giving the rows for entries[[1]]
and entries[[2]]
, whose difference is 1.
NULL
if no consecutive entries
are found in col_name
.
DF <- data.frame(C1 = c("A", "B", "C"))
DF %>% adjacent_rownums("C1", c("A", "B"))
DF %>% adjacent_rownums("C1", c("B", "C"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.