[R] Computing Median for Subset of Data

Berend Hasselman bhh at xs4all.nl
Sun Jun 2 09:50:09 CEST 2013


On 02-06-2013, at 08:08, Matt Stati <mattstati at yahoo.com> wrote:

>> From my larger data set I created a subset of it by using: 
> 
> subset_1 <- subset(timeuse, IndepTrans = 1, Physical = 1)
> 
> where my larger data set is "timeuse" and the smaller subset is "subset_1". The subset was conditioned on "IndepTrans" equaling "1" in the data and "Physical" equaling "1" as well. I want to be able to compute the median of a variable first for the larger data set "timeuse" then for the subset file "subset_1". How do I identify to R which data set I'm wanting the median computed for? I've tried many possibilities but for some reason can't figure it out. 


?with

with(timeuse, median(…))
with(subset_1, median(…))

Berend



More information about the R-help mailing list