Communities for your favorite technologies. Explore all Collectives
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
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.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.