How to find Nth smallest value in vector in R ? (original) (raw)

Last Updated : 23 Jul, 2025

In this article, we will discuss how to find the Nth smallest in vector in the R programming language.

Steps -

Syntax:

sort(vector name ) [n value])

Parameter:

Example 1:

R `

a<- c(1,3,4)

x = readline(); x = as.integer(x);

print(sort(a)[x])

`

Output:

[1] 1

Example 2:

R `

a<- c(3453,39898,-997784)

x = readline(); x = as.integer(x);

print(sort(a)[x])

`

Output:

[1] 39898