For example I have a 5x1 dataframe and I want to loop over all the rows and I want to use the character that is in each observation and store it as a value, how can this be done? I cannot seem to circumvent it being saved as a tibble which prevents me from using said observation as a input in a function.
Asked
Active
Viewed 100 times
0
-
Please provide your code with an example of your data and your expected outcome. – Phil Sep 26 '22 at 18:17
-
Your question is a little unclear and mostly hypothetical. It will be much easier to answer (and more inline with Stack's *"Specific programming problems"*) if you provide a more reproducible (concrete) question, including sample data (i.e., provided using `data.frame`, `read.table`, or `dput`, to name three methods), expected output, and code attempted. Some good refs that discuss these in more depth: https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info – r2evans Sep 26 '22 at 18:18
1 Answers
0
You can use pluck
:
library(tidyverse)
df <- tibble(value = c("a", "b", "c"))
df %>%
pluck("value", 2)
#> [1] "b"
Created on 2022-09-26 with reprex v2.0.2

Allan Cameron
- 147,086
- 7
- 49
- 87