Let's take the following simplified version of a dataset that I import using read.table
:
a<-as.data.frame(c("M","M","F","F","F"))
b<-as.data.frame(c(25,22,33,17,18))
df<-cbind(a,b)
colnames(df)<-c("Sex","Age")
In reality my dataset is extremely large and I'm only interested in a small proportion of the data i.e. the data concerning Females aged 18 or under. In the example above this would be just the last 2 observations.
My question is, can I just import these observations immediately without importing the rest of the data then using subset
to refine my database. My computer's capacities are limited and so I have been using scan
to import my data in chunks but this is extremely time consuming.
Is there a better solution?