Get or Set the Type of an Object in R Programming – mode() Function
Last Updated :
19 Jun, 2020
mode()
function in R Language is used to get or set the type or storage mode of an object.
Syntax:
mode(x)
mode(x) <- value
Here "value" is the desired mode or ‘storage mode’ (type) of the object
Parameters:
x: R object
Example 1:
x < - 3
y < - "a"
mode(x)
mode(y)
|
Output:
[1] "numeric"
[1] "character"
Example 2:
x < - 3
y < - "a"
mode(x) < - "character"
mode(y) < - "numeric"
mode(x)
mode(y)
|
Output:
[1] "character"
[1] "numeric"
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...