Hi! I have two questions. For that, I would like to share my reprex:
library(tidyverse)
set.seed(1234) #win-10 OS
a <- list(runif(100))
b <- list(runif(99))
c <- list(runif(98))
d <- list(runif(97))
Column_Asked <- c(a,b,c,d)
df_reprex <- tibble::tibble(Column_Asked)
pluck(df_reprex$Column_Asked,1)[1] # gives 0.1137
pluck(df_reprex$Column_Asked,2)[1] # gives 0.03545673
What I want to do is - how the reprex shows - to find a way to extract the first element of each list that composes the column "Column_Asked" of "df_reprex". Is there a better way than use pluck for that?
A problem with this approach is that the "df" that I am working, my "Column_Asked" has almost 75k rows. For that, I just create this function - using the df_reprex's number of rows - :
extract_data_reprex <- function(data){
i <- 0
b <- c(0)
for(i in 1:4){
b[i] <- pluck(df_reprex$Column_Asked,i)[1]
}
return(tibble(Data_Requested = b))
}
extract_data_reprex()
However, pluck - in my formula - requires (for the use of pluck) a vector named "df_reprex$Column_Asked". So, is there a better way to subset a dataframe using rlang?. In the same df, there are almost 7 "Column_Asked"
Please, any help will be highly appreciated.
Thanks
PS If there is something unclear, please let me know.