How to find the minimum value of a column in R?

r

Solution

If you need minimal value for particular column

min(data[,2])

Note: R considers `NA` both the minimum and maximum value so if you have NA's in your column, they return: `NA`. To remedy, use:

min(data[,2], na.rm=T)

Problem

I am new in R and I am trying to do something really simple. I had load a txt file with four columns and now I want to get the minimum value of the second column. This is the code that I have: ``` ## Choose the directory of the file setwd("//Users//dkar//Desktop") ## Read the txt file data<-read.table("export_v2.txt",sep="",header=T) str(data) ## this command gives me the minimum for all 4 columns!! a<-apply(data,2,min) ``` Actually, if I want to do something like this: min (data(:,2)). But I don't know how to do it in R. Any help?

Original source