Just use matrix indexing, like this:
dframe[cbind(seq_along(i), i)]
# [1] "g" "b" "f"
The cbind(seq_along(i), i)
part creates a two column matrix of the relevant row and column that you want to extract.
More Related Contents:
- Sum by two variables
- How to make plots from distributed data from R
- Drop unused factor levels in a subsetted data frame
- Use dynamic name for new column/variable in `dplyr`
- Rcpp package doesn’t include Rcpp_precious_remove
- data.table vs dplyr: can one do something well the other can’t or does poorly?
- Changing fonts in ggplot2
- Nested facets in ggplot2 spanning groups
- Add a month to a Date [duplicate]
- How to run R on a server without X11, and avoid broken dependencies
- How should I deal with “‘someFunction’ is not an exported object from ‘namespace:somePackage'” error? [closed]
- Error in if/while (condition) { : argument is of length zero
- How do I get the classes of all columns in a data frame? [duplicate]
- Set locale to system default UTF-8
- How to change ‘Maximum upload size exceeded’ restriction in Shiny and save user file inputs?
- plotly: Updating data with dropdown selection
- Use filter in dplyr conditional on an if statement in R
- Finding the index inside a vector satisfying a condition
- What is about the first column in R’s dataset mtcars?
- R – ggplot2 issues with date as character for x-axis
- Using If/Else on a data frame
- dplyr / R cumulative sum with reset
- finding close match from data frame 1 in data fame 2
- ggplot2: Setting geom_bar baseline to 1 instead of zero
- aggregate() puts multiple output columns in a matrix instead
- Remove ‘search’ option but leave ‘search columns’ option
- select columns based on multiple strings with dplyr contains()
- Plot background colour in gradient
- Importing csv file into R – numeric values read as characters
- Read csv from specific row