Quantcast
Channel: R: Swap two variables without using a third - Stack Overflow
Viewing all articles
Browse latest Browse all 9

R: Swap two variables without using a third

$
0
0

I have two variables (i.e.):

   a <- 1   b <- 2

and I would like to swap their values. Is there any built-in R function, that is able to perform that operation? Or is there an other elegant way, without using a third (temp) variable?

Note: If possible applicable on strings, or other datatypes.


Viewing all articles
Browse latest Browse all 9

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>