> age <- c(1,2,3)
> weight <- c(4,5,6)
> p <- data.frame(age=age, height=height)
> p
age height
1 1 4
2 2 5
3 3 6
> p[p$age > 1,]
age height
2 2 5
3 3 6
> age
[1] 1 2 3
> age.df <- data.frame(age=age)
> age.df
age
1 1
2 2
3 3
> age.df[age.df$age > 1,]
[1] 2 3
I want the subset of the dataframe that I asked for, not a vector, in which the rownames and column names are lost. Why does R do this? Can it be prevented?