1

I have a string like that

mystring<-"A+B+C"

a data where A, B and C as varialles. How do I get this into a command like

x<-A+B+C

using mystring as above. Thanks for any hint

1 Answer 1

1

You can use eval and parse

A <- 1
B <- 2
C <- 3
x <- eval(parse(text = "A+B+C"))
x
## [1] 6
Sign up to request clarification or add additional context in comments.

Comments

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.