0

Can I execute rscript from string? Like this

> execute("d<-0") # function or command?..
> d[1]
[1] 0

Thanks

0

1 Answer 1

5

You can do

> eval(parse(text = "d<-0"))
> d[1]
[1] 0

But, as always:

fortunes::fortune("answer is parse")

If the answer is parse() you should usually rethink the question. -- Thomas Lumley R-help (February 2005)

Sign up to request clarification or add additional context in comments.

3 Comments

@NelsonGon: For the record, I did not downvote your answer.
It doesn't matter, I'm mostly here to learn but I get many of these scenarios daily. It's like people are competing to be right. Not saying this was the case!
@NelsonGon: Yeah, I get what you mean. I'm probably guilty of that too, from time to time.

Your Answer

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.

Ask question

Explore related questions

See similar questions with these tags.