I want to save based on a variable.
t="Cis"
d="1083"
For this run, I had to use the following to create my named dataset based on these assigned variables.
assign(paste0(t,"_",d,"_","tcpl.pod"), data.frame(c1,c2,c3,c4,c5))
This worked and created my dataframe with name = Cis_1083_tcpl.pod
This is important to me, because I will want to loop through different values for t
and d
.
Question 1: I always hear "AVOID USING ASSIGN!" Is there a better way of achieving the above?
Question 2: I want to save that object and still refer to it based on the coding as follows:
save(paste0(t,"_",d,"_","tcpl.pod"), file = paste0(t,"_",d,"tcpl.pod.RData"))
This gives error that the 'paste0(t,"_",d,"tcpl.pod.RData"))'
not found.
How do I refer to the first paste construction appropriately in R?
P.S.
save(get(paste0(t,"_",d,"_","tcpl.pod")), file = paste0(t,"_",d,"tcpl.pod.RData"))
returns the same error.