MotaF - 7 months ago 56

R Question

I am converting MATLAB code into R

`xmin=floor( min( min(min(per1),min(per2)) , min(min(per3),min(per4)) ) );`

Mathworks says

`floor`

Does the R function floor performs the same job?I do not have MATLAB installed,that I can compare the two.

Answer

`?floor`

says

‘floor’ takes a single numeric argument ‘x’ and returns a numeric vector containing the largest integers not greater than the corresponding elements of ‘x’.

The MATLAB help online describes `floor`

as "round toward negative infinity", and the actual help text is

Y = floor(X) rounds each element of X to the nearest integer less than or equal to that element.

Since R's `min()`

function takes multiple arguments, I think

```
xmin <- floor( min(per1,per2,per3,per4))
```

should be fine.

Source (Stackoverflow)