as.vector()
function in R Language is used to convert an object into a vector.
Syntax: as.vector(x)
Parameters:
x: Object to be converted
Example 1:
# R program to convert an object to vector # Creating an array x <- array(c(2, 3, 4, 7, 2, 5), c(3, 2)) x # Calling as.vector() Function as.vector(x)
Output:
[, 1] [, 2] [1, ] 2 7 [2, ] 3 2 [3, ] 4 5 [1] 2 3 4 7 2 5
Example 2:
# R program to convert an object to vector # Creating a matrix x <- matrix(c(1:9), 3, 3) x # Calling as.vector() Function as.vector(x)
Output:
[, 1] [, 2] [, 3] [1, ] 1 4 7 [2, ] 2 5 8 [3, ] 3 6 9 [1] 1 2 3 4 5 6 7 8 9
Australia
UK
UAE
Singapore
Canada
New
Zealand
Malaysia
USA
India
South
Africa
Ireland
Saudi
Arab
Qatar
Kuwait
Hongkong
Copyright 2016-2023 www.programmingshark.com - All Rights Reserved.
Disclaimer : Any type of help and guidance service given by us is just for reference purpose. We never ask any of our clients to submit our solution guide as it is, anywhere.