I send the first parameter which is a formula, that's our analysis variable,
and to make sure it treats that as a factor, use yes, no variable.
I say factor here, and then delay.med in parentheses.
So factor is a kind of a function that's receiving delay.med.
And then the stub of the table is going to be age groups.
So there's a variable called age.grp in the file, I used that.
The function FUN here is survey mean, so I specify that.
There are other possibilities, survey total, for example.
You tell it the design object, which I just created.
And then, it's critical, but you include this na.rm=TRUE,
which means If the analysis variable or
the stub of the table has missing values, just take those out.
Otherwise, you're not going to get a table.
Now, the survey package does not tabulate those missing's out separately.
It might be nice if it did, but it doesn't ,you'd have to code them as
something other than na in order to get those to be tabulated.
So I save all that in an object called age.mns, mns for means.
And then it turns out the two columns out of this object that I want to look at for
the proportion and the standard error are the second and the fourth.
So I'm extracting those here.
And then just to make my table a little more readable, I specify rownames and
colnames for this age.mns object.
The second and fourth columns, which is what I extracted and
then I print those out here with the round function around four decimal places.
So you can see in the proportion column here, the proportions or
lower for young people under 18 years old, and older people,
65 or more, then they are for people in the working years.
And reason for that is that in the US all the young tend to have
medical insurance at a higher rate than the working age people.
So because they've got insurance, they tend not to delay treatment.
So here are the standard errors.
You can see they're a bit different.
And those are the width replacement standard errors.