127k views
1 vote
If I execute the expression x <- 4L in R, what is the class of the object `x' as determined by the `class()' function?

1 Answer

2 votes

Answer:

integer

Step-by-step explanation:

The expression can be implemented as follows:

x <- 4L

class(x)

Here x is the object. When this expression is executed in R, the class "integer" of object 'x' is determined by the class() function. R objects for example x in this example have a class attribute determines the names of the classes from which the object inherits. The output of the above expression is:

"integer"

Here function class prints the vector of names of class i.e. integer that x inherits from. In order to declare an integer, L suffix is appended to it. Basically integer is a subset of numeric. If L suffix is not appended then x<-4 gives the output "numeric". Integers in R are identified by the suffix L while all other numbers are of class numeric independent of their value.

If I execute the expression x <- 4L in R, what is the class of the object `x' as-example-1
User Trent Stewart
by
3.9k points