Need help in Quote & Unquote of .env variable

I am writing R function which will read parquet file format from different path.

User variable "Path" resolves correctly. however user variable study_name which has value as "Harmo" doesn't resolve properly.

It does not set Output data frame in function with name as "Harmo", It output data Frame with "Study_name" only. I want output data frame as "Harmo" instead of "study_name".

R Code as follows

User variable

path <- "c://document"
study_name <- "Harmo"

Function to Read Dataframe

read_df <- function(path, study){
object <- s3$get_object(Bucket= bucket_name, Key = path)
data <- object$Body
study_name <<- read_parquet(data)
}

Function call

read_df(path = path_harmo , study = study_name)

R is typically used as a functional language, where we try to use pure functions when possible. So we would usually avoid assigning things in the global environment from inside the function, and prefer a function that just returns the right thing:

read_df <- function(path){
object <- s3$get_object(Bucket= bucket_name, Key = path)
data <- object$Body
read_parquet(data)
}

Harmo <- read_df(path = path_harmo)

Is there a reason you want to avoid this format? If it's to create objects in a loop, the good practice is to use a named list:

paths <- c("path/to/first", "path/to/second")
study_names <- c("Harmo", "Harmo2")


stopifnot(length(study_names) == length(paths))

res <- lapply(paths, read_df) |>
  setNames(study_names)