How to assign the result of the previous expression to a variable?

RReturn ValueInteractiveBuilt In

R Problem Overview


Suppose I'm using R's interactive console, and I've just done something like this:

long_running_command()

That long-running command returns a value, and I've just realized that I wanted to assign that value to a variable instead of discard it. So how can I get that value without running the command again? Is there a command like this?

result = get_last_return_value()

R Solutions


Solution 1 - R

.Last.value is an answer.

It was answered once but you have better title.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRyan C. ThompsonView Question on Stackoverflow
Solution 1 - RMarekView Answer on Stackoverflow