S
Swetha Shetty

Posted on 7th May 2024|401 views

0
votes

Number Of Items To Replace Is Not A Multiple Of Replacement Length

Why am I getting an error number of items to replace is not a multiple of replacement length?

this is the code I am using

combi$DT[is.na(combi$DT) & ! is.na(combi$OD) ] <- combi$OD

 

Answers
P
Anusha V

Posted on 7th May 2024

The warning is displayed because you are attempting to assign total combi$OD to the areas wherever combi$DT is NA. For instance, if you hold 100 rows of 2 variables among 5 NAs, then you are saying it to substitute those 5 NAs of variable1 by the 100 values regarding variable2. So the warning. Work with this instead,

combi$DT[is.na(combi$DT) & !is.na(combi$OD)] <- combi$OD[is.na(combi$DT) & !is.na(combi$OD)]

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos