Skip to content
Prev 337093 / 398528 Next

Basic question for subset of dataframe

Try a simpler example:
x a   c  y
1 1 a Jan 11
2 2 b Feb 12
3 3 c Mar 13
4 4 d Apr 14
5 5 e May 15
a
1 a
2 b
3 c
4 d
5 e
c
1 Jan
2 Feb
3 Mar
4 Apr
5 May

If you use [] without a comma, it returns the specified columns.

  ick[ c(FALSE,TRUE,TRUE,FALSE) ]

will return the second and third columns, those where the logical vector
is TRUE.

This is because data frames are actually lists in disguise
-Don