Here's my code:

```m <- matrix(c(1:5,NA,7,7,NA),
nrow=3,ncol=3,byrow=T)
print(m)
for ( i in 1:dim(m)[[1]] ) {
mm <- sort(m[i,],na.last=c(NA,NA,T)[[i]])
for ( j in 1:(length(mm)-1) ) {
if ( mm[[j]]==mm[[j+1]] ) {
cat(i,j,mm[[j]],fill=T)
}
}
}```

On executing this I get an error:

"Error in if (mm[[j]] == mm[[j + 1]]) { : missing value where TRUE/FALSE needed "

May 28, 2019 21,655 views

## 1 answer to this question.

This should work:

```for ( i in 1:dim(m)[[1]] ) {
mm <- sort(m[i,],na.last=c(NA,NA,T)[[i]])
for ( j in 1:(length(mm)-1) ) {
if ( isTRUE(mm[[j]]==mm[[j+1]]) ) {
cat(i,j,mm[[j]],fill=T)
}
}
}```
• 910 points
THANK YOU SO MUCH, MAY GOD BLESS YOU IF YOU BELIEVE IN HIM, IF NOT, THEN I WISH YOU LUCK IN YOUR LIFE, YOU SAVED ME AND MY FELLOW STUDENTS
Hello, @Nouha,

Happy Learning

## R programming Error: Error in if (d >= 0) { : missing value where TRUE/FALSE needed

Here is my code: for(i in 1:(nrow(moon_sub))){   l_df[i,] <- ...READ MORE

+1 vote

## R programming: Missing value error

You can achieve this by wrapping isTRUE() around your if-condition: for ...READ MORE

## Error: could not find function - R Programming

Yes, Just like @Maverik said, It happens ...READ MORE

+1 vote

## How to sort a data frame by columns in R?

You can use dplyr function arrange() like ...READ MORE

## How to remove certain character from a vector

We can use sub to remove the * by specifying fixed = ...READ MORE

## What are special values in R

Like most programming languages, R has a ...READ MORE

## What does the inf special character mean in R?

inf stands for infinity and only applies ...READ MORE