To create two-way table in R, you can use table() function.

The following method shows how you can do it with syntax.

Method 1: Use table() Function

table(vector1,vector2)

The following example shows how to create two-way table in R.

Using table() Function

Let’s see how we can use table() function to create two-way table in R:

# Create matrix
data=matrix(c(78,89,85,84,81,79,77,85),ncol=2)

# Create table
Machine_info <- table(data)

# Show table 
print(Machine_info)

Output:

data
77 78 79 81 84 85 89 
 1  1  1  1  1  2  1 

Here the output shows two-way created using table() function.