# Create Multiplication Table in R (Example)

In this R tutorial you’ll learn how to construct a multiplication table.

The content of the page looks like this:

It’s time to dive into the programming part!

## Example: Create Multiplication Table Using a Manually Defined Function

In this example, I’ll demonstrate how to compute and create a multiplication table in the R programming language.

For this task, we first have to create a user-defined function:

```fun_multtab <- function(x, len) { # Create function for multiplication table for(i in 1:len) { print(paste(x, "*", i, "=", x * i)) } }```

Next, we can apply this manually defined function to create a multiplication table for a certain input value with a certain length.

The example below constructs a multiplication table for the value 5 up to the multiplier 10:

```fun_multtab(x = 5, len = 10) # Apply user-defined function #  "5 * 1 = 5" #  "5 * 2 = 10" #  "5 * 3 = 15" #  "5 * 4 = 20" #  "5 * 5 = 25" #  "5 * 6 = 30" #  "5 * 7 = 35" #  "5 * 8 = 40" #  "5 * 9 = 45" #  "5 * 10 = 50"```

We can insert basically every input we want to our function. Let’s execute it once again with the values 3 and 7:

```fun_multtab(x = 3, len = 7) # Different input values #  "3 * 1 = 3" #  "3 * 2 = 6" #  "3 * 3 = 9" #  "3 * 4 = 12" #  "3 * 5 = 15" #  "3 * 6 = 18" #  "3 * 7 = 21"```

Looks good!

## Video & Further Resources

Do you need more information on the R programming syntax of this article? Then you may watch the following video on my YouTube channel. In the video, I demonstrate the examples of this tutorial in RStudio.

In addition, you might have a look at some of the other tutorials on my homepage. Some related articles that are related to the construction of a multiplication table are listed below:

You have learned in this article how to calculate a multiplication table in the R programming language. Please let me know in the comments section below, in case you have additional comments or questions.

Subscribe to the Statistics Globe Newsletter