-4

I have one tab delimited file.

cat file

A      B     C
2      3     4 
3      4     5
2      6     6

infile<-read.table("file",header=TRUE)

I need to get value for column which has header = "A".

 A 
 2
 3
 2

How can i get it?

Manish
  • 3,341
  • 15
  • 52
  • 87

2 Answers2

4

For a single column data.frame as the output:

infile["A"]
infile[1]

For a vector as the output:

infile[, "A"]
infile[, 1]
infile[["A"]]
infile[[1]]
infile$A
A5C1D2H2I1M1N2O1R2T1
  • 190,393
  • 28
  • 405
  • 485
1

infile$A should work. You need read R book more and then to start your programming trials.

Leo5188
  • 1,967
  • 2
  • 17
  • 21