Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
in R,the pdf function can save graph in c:/test:
c:/test
pdf("c:/test")
I want to make a variable substitue pdf ,how can i make it run ?
str<-"pdf" str("c:/test")
get() does this:
get(str)("c:/test")
Add a comment
s = "pdf" ; do.call(s, list("c:/test"))
or in two steps,
cl <- call(s, "c:/test") eval(cl)
You can extract the function specified by the name in str with match.fun:
str
match.fun
match.fun(str)("c:/test")
By the way: It is not a good idea to name an object str since this is the name of a basic function in R.
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.