简体   繁体   中英

Quick command to assign a value to a variable and print it

Basically I would like one command which replaces the following two commands:

temp <- 5^2-2
print("temp")

I would like to see the result of the calculation assigned to temp without having to use the print() command.

您可以将整个表达式放在方括号中。

(temp <- 5^2-2)

您可以通过以下方式进行组合:

temp <- print(5^2-2)

You may use the .Last.value function, like this:

temp <- 5^2-2
.Last.value

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM