I've been working with R for the past week to transfer my VBA code. I worked on a loop with my father to assign a data frame column with values from another data frame column, but I am getting an error back: Error in as.environment(pos) : invalid 'pos' argument. Since my knowledge and experience of R is limited, I do not know if I should be using a different function or how to fix my line of code.
The Q_new$Vol..mL variable contains 517 rows of numbers such as 69, 68, 68, 67, 66, 65, 64, 64, 63, 62, 61,60, 79, 78, 77 .... The Infil_Data.Time.1$m contains 517 rows of no data (a blank cell). What I want to do is take the first number of every 12th row from the Q_new$Vol..mL variable and duplicate it down 12 times in the Infil_Data.Time.1$m variable. So it should look like 69,69,69,69,69,69,69,69,69,69,69,69,79,79,79,79,79,79,79,79,79,79,79,79....
I used the reprex as R Studio Community recommend. Let me know if what I have below is not properly formatted. Or additional information is needed.
jeff <- while (!is.null(Q_new$Vol..mL)) {
for (x in 1:11) {
R1 <- R1 + 1 %>% assign(Infil_Data.Time.1$m, Q_new[R2,
1]) %>% (next)(x)
}
R2 = R2 + 1
}
#> Error in eval(expr, envir, enclos): object 'Q_new' not found