Get Minimum value of a column in R

Minimum value of a column in R can be calculated by using min() function. Let’s see how to calculate minimum value in R with an example.

Let’s first create the dataframe.

### Create Data Frame
df1 = data.frame(Name = c('George','Andrea', 'Micheal','Maggie','Ravi','Xien','Jalpa'), 
                 Grade_score=c(4,6,2,9,5,7,8),
                 Mathematics1_score=c(45,78,44,89,66,49,72),
                 Science_score=c(56,52,45,88,33,90,47))
df1

So the resultant dataframe will be

Get Minimum value of a column in R 1

 

Get minimum value of the column in R

Method 1:

Get minimum value of the column by column name

# Get minimum value of the column by column name

min(df1$Mathematics1_score)

Result:

[1] 44

 

Method 2:

Get minimum value of the column by column position

# Get minimum value of the column by column position

min(df1[,3])

Result:

[1] 44

 

 

Get Minimum value of a column in R - image previous-small-11-1 on http://www.datasciencemadesimple.com                                                                                                               Get Minimum value of a column in R - image next_small-11-1 on http://www.datasciencemadesimple.com