Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between objects and variables?

Tags:

r

I want to know the difference between Variables and Objects in R. Is 'a'in the code provided an object or variable ? Where this a is going to be save, in heap or stack ?

a <- 1
like image 735
Hasnain Avatar asked Feb 22 '26 12:02

Hasnain


1 Answers

There is no difference, from a data type perspective, between 1 and c(1,2,3). Everything in R is an object. For instance:

a <- 1
b <- c(1,2,3)
typeof(a)==typeof(b)
#[1] TRUE
class(a)==class(b)
#[1] TRUE

R is a high level language and you don't have visibility on where and when R actually allocates memory.

like image 189
nicola Avatar answered Feb 25 '26 06:02

nicola



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!