What is the replacement length of items in Rstudio?

663    Asked by BellaBlake in Data Science , Asked on Feb 25, 2021
Answered by Bella Blake

The error which you are getting advises that are a number of items to replace is not a multiple of replacement length utilize the accompanying code for instance:

## create a matrix that is 6 rows and 2 columns

mat <- matrix(1:12, 6,2)

## try to replace first column with a vector of length 3

## works fine because 6 is a multiple of 3

mat[,1] <- 1:3

## try to replace first column with a vector of length 5

## Fails because 6 is not a multiple of 5, try the same exception.

mat[,1] <- 1:5

## number of items to replace is not a multiple of replacement length

Subsequently, you need to rethink your application articulation. Try storing the results in the list than in the matrix.

On the off chance that you need to find out about Data Science, at that point do look at the accompanying Data Science which will help you in understanding Data Science without any preparation



Your Answer

Interviews

Parent Categories