set.seed(2023)
pid <- 1:30
y1 <- rnorm(30, 10, 10)
y2 <- rnorm(30, 10, 10)
x1 <- rnorm(30, 5, 2)
x2 <- rnorm(30, 5, 2)
x3 <- rnorm(30, 300, 3)
This is minimal reproducible data. I want to make a function as below.
try <- function(data, a, b) {
data <- data %>%
mutate(paste0(a, b, "manual_mean") = ({{a}} + {{b}}) /2
)
return(data)
}
so, a and b will be column names from data.
t<-try(data2,y1,y2)
and I tried this try() function. I expect that I have a new column named as "y1y2manualmean" but it throws an error.