Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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() 
like image 988
Ryan C. Thompson Avatar asked Sep 11 '10 00:09

Ryan C. Thompson


People also ask

How do you assign a result to a variable?

The = symbol is known as the assignment operator. It is also possible to declare a variable and assign it a value in the same line, so instead of int i and then i = 9 you can write int i = 9 all in one go. If you have more than one variable of the same type you can also declare them together e.g.

What is another way to assign value to a variable?

You can assign a value to a routine variable in any of the following ways: Use a LET statement. Use a SELECT INTO statement. Use a CALL statement with a procedure that has a RETURNING clause.

What does it mean to assign a value to a variable?

To "assign a value to a variable" is something you tell the computer to do. Once the value has been assigned to the variable, the variable holds that value. To "assign a variable to a value" is something you do. It means to designate a specific variable to hold a certain value.


1 Answers

.Last.value is an answer.

It was answered once but you have better title.

like image 171
Marek Avatar answered Oct 07 '22 15:10

Marek