I want to identify which row matches the information in a vector. As an example, I'll use the iris
dataset (in tibble
format to better approximate my situation): iris %>% as_tibble()
. Then I have a tibble with a single row, which came directly from the original dataset:
choice <– structure(list(Sepal.Length = 4.5, Sepal.Width = 2.3, Petal.Length = 1.3,
Petal.Width = 0.3, Species = structure(1L, .Label = c("setosa",
"versicolor", "virginica"), class = "factor")), row.names = c(NA,
-1L), class = c("tbl_df", "tbl", "data.frame"))
# A tibble: 1 x 5
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
<dbl> <dbl> <dbl> <dbl> <fct>
1 4.5 2.3 1.3 0.3 setosa
I want to identify which row matches this exactly. I think it's better if it's a vector, but that's going to depend on what the function is; if that's the case, than you just have to add an as.numeric()
to that choice
.
The correct row is 42.