Skip to content
Prev 361152 / 398506 Next

Sprintf to call data frame from environment

It is not clear (at least to me) what your actual task is.  But, if Samples_1.txt is the actual name of a data frame that exists in memory (and not a filename), then you need to wrap the sprintf() in a get() function.

get(sprintf("Samples_%s.txt", 1))$V1

I am no expert  on "computing on the language" in R, but I can't help but think you are going about your task in the wrong way.  If you provide more detail about what you are trying to do, someone will probably be able to provide you a solution where you don't need to do it this way.


Hope this is helpful,

Dan

Daniel Nordlund, PhD
Research and Data Analysis Division
Services & Enterprise Support Administration
Washington State Department of Social and Health Services