pmap ! object '.f' not found

Why won't this code run?

library(tidyverse)

df <- 
  expand.grid(
    rho2 = c(.10, .20), 
    rho3 = c(.05, .15), 
    r21 = c(.3, .6), 
    r22 = c(.02, .05),
    r23 = c(.05, .20)
  ) %>% 
  as.data.frame() %>% 
  mutate(
    power = .80,
    alpha = .05,
    two.tailed = TRUE,
    p = .50,
    g3 = 2,
    n = 5, 
    J = 3,
    K = 8
  ) %>% 
  select(power, alpha, two.tailed, rho2, rho3, p, g3, r21, r22, r23, n, J, K)

pmap(df, PowerUpR::mdes.cra3)

First of all the .l object in pmap() is meant to be a list. You are just passing in a dataframe.

this seems to work :

library(tidyverse)
library(PowerUpR)
df <-
  expand.grid(
    rho2 = c(.10, .20),
    rho3 = c(.05, .15),
    r21 = c(.3, .6),
    r22 = c(.02, .05),
    r23 = c(.05, .20)
  ) %>%
  as.data.frame() %>%
  mutate(
    power = .80,
    alpha = .05,
    two.tailed = TRUE,
    p = .50,
    g3 = 2,
    n = 5,
    J = 3,
    K = 8
  ) %>%
  select(
    power, alpha, two.tailed, rho2, rho3, p, g3, r21,
    r22, r23, n, J, K
  )

my_args <- c(
  "power", "alpha", "two.tailed", 
  "rho2", "rho3", "p", "g3", "r21",
  "r22", "r23", "n", "J", "K"
)

(d2 <- mutate(rowwise(df),
  inputs_list = list(mget(my_args,
    envir = as.environment(cur_data())
  )),
  results = list(do.call(what = PowerUpR::mdes.cra3, 
                         args = inputs_list))
) |> ungroup())

Well, the documentation also says: " A data frame is an important special case of .l . It will cause .f to be called once for each row."

So I do not see how my case is different from the documentation example:

df <- data.frame(
  x = c("apple", "banana", "cherry"),
  pattern = c("p", "n", "h"),
  replacement = c("P", "N", "H"),
  stringsAsFactors = FALSE
  )
pmap(df, gsub)

thats cool, I didnt know that feature. It only doesnt work because of the design of PowerUpR::mdes.cra3 ; and the way that it internally uses eval

Thank you so much for your solution!

I found a more succinct solution:

d_less <- pmap(df,
           \(x,...){
             do.call(what = PowerUpR::mdes.cra3, 
                     args = rlang::list2(...))
           
           })

This is very elegant, thank you so much! I wish I understood it, but it is enough now that it works beautifully!