Is it possible to use the argument passed to a function to create an object name within the function? For example in the code below I'm trying to check the value of use_x and create a data table called "x_list":
use_x = "Y"
myfun <- function(type_name){
if (eval(parse(text= paste("use_",type_name, sep = "") )) == "Y"){
type_name_list <- data.table(item = 1, name = "some name here", condition = "Y")}
}
myfun("x")