0

I am looking to build strings, that should be the input for executing a command. The string is ready and constructed as described below.

Question:

How can I send the content of the string as a command?

# Build list with content
my_list <- list("no1" = 12)

# Define content, parts of string.
text_left  <- "ls.str("
text_right <- ")"

# Build string.
test_string_result <- paste0(
  text_left,
  "my_list",
  text_right
)

# Result of string.
print(string_result)

The printout of command "print(string_result), gives:

[1] "ls.str(my_list)"

Wanted result:

I want the "string_result" to be the base for sending the content as a command, e.g. it should send "ls.str(my_list)

1
  • 1
    eval(parse(text = test_string_result)). Commented Jul 3, 2019 at 10:51

1 Answer 1

1

Use eval(parse(text=print(test_string_result)))

Results in:

no1 : num 12
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.