R Error: non-conformable arguments (2 Examples)
In this tutorial you’ll learn how to deal with the error message “non-conformable arguments” in R programming.
Creating Exemplifying Data
data_1 <- matrix(5) # Create example data in R data_1 # [,1] # [1,] 5 |
data_1 <- matrix(5) # Create example data in R data_1 # [,1] # [1,] 5
data_2 <- matrix(1:9, ncol = 3) data_2 # [,1] [,2] [,3] # [1,] 1 4 7 # [2,] 2 5 8 # [3,] 3 6 9 |
data_2 <- matrix(1:9, ncol = 3) data_2 # [,1] [,2] [,3] # [1,] 1 4 7 # [2,] 2 5 8 # [3,] 3 6 9
Example 1: Replicate Error: non-conformable arguments
data_1 %*% data_2 # Trying to multiply data objects # Error in data_1 %*% data_2 : non-conformable arguments |
data_1 %*% data_2 # Trying to multiply data objects # Error in data_1 %*% data_2 : non-conformable arguments
Example 2: Solve Error: non-conformable arguments
as.vector(data_1) * data_2 # Converting m1 to vector # [,1] [,2] [,3] # [1,] 5 20 35 # [2,] 10 25 40 # [3,] 15 30 45 |
as.vector(data_1) * data_2 # Converting m1 to vector # [,1] [,2] [,3] # [1,] 5 20 35 # [2,] 10 25 40 # [3,] 15 30 45