You can use max. If you provide the row as a vector and use max just make sure you set na.rm = TRUE.
Here is an example using a vector:
> x = c(2,4,6,10,1,5,NA)
> max(x,na.rm = TRUE)
[1] 10
Here is an example using a matrix:
> x = matrix(1:10,2,5)
> x
[,1] [,2] [,3] [,4] [,5]
[1,] 1 3 5 7 9
[2,] 2 4 6 8 10
> x[2,2] = NA
> x
[,1] [,2] [,3] [,4] [,5]
[1,] 1 3 5 7 9
[2,] 2 NA 6 8 10
> max(x[2,],na.rm = TRUE)
[1] 10
Here is a simple for loop demonstration:
for(i in 1:nrow(x)){
y[i] = max(x[i,],na.rm = TRUE)
}
> y
[1] 9 10