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)

Toolbox
  • 2,333
  • 12
  • 26

1 Answers1

1

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

Results in:

no1 : num 12
Alex
  • 504
  • 3
  • 10