as.table()
function in R Language is used to convert an object into a table.
Syntax: as.table(x)
Parameters:
x: Object to be converted
Example 1:
vec = c( 2 , 4 , 3 , 1 , 2 , 3 , 2 , 1 , 4 , 2 )
as.table(vec)
|
Output:
A B C D E F G H I J
2 4 3 1 2 3 2 1 4 2
Example 2:
mat = matrix(c( 1 : 9 ), 3 , 3 )
mat
as.table(mat)
|
Output:
[, 1] [, 2] [, 3]
[1, ] 1 4 7
[2, ] 2 5 8
[3, ] 3 6 9
A B C
A 1 4 7
B 2 5 8
C 3 6 9
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!