Hi Chris,
Sorry for the late response. The following selects all students that have
never been suspended:
> with(susim, tapply(sus, id_r, function(x) all(x == 0)))
999881 999886 999890 999892 999896 999897
FALSE TRUE TRUE TRUE FALSE TRUE
> r <- with(susim, tapply(sus, id_r, function(x
On Thu, Apr 7, 2011 at 8:07 AM, Christopher Desjardins <
cddesjard...@gmail.com> wrote:
> Hi Jorge,
> I want to make sure this does what I want.
>
> So I want to get a count of students that never get a suspension. Once a
> student has a non-zero I don't want to count that student. Each id_r is ma
Hi Jorge,
I want to make sure this does what I want.
So I want to get a count of students that never get a suspension. Once a
student has a non-zero I don't want to count that student. Each id_r is may
be associated with multiple sus. Are these commands doing this? Because ...
> suslm[175953:nrow
Hi:
Another approach would be to use xtabs(). Letting df represent your example
data frame,
(u <- with(df, xtabs(sus ~ id_r)))
# IDs returned as a character vector:
> names(u)[u == 0L]
[1] "11" "16" "18" "19" "20" "21" "22" "24" "26" "30" "31" "32" "33"
HTH,
Dennis
On Wed, Apr 6, 2011 at 2:10
On Wed, Apr 6, 2011 at 4:03 PM, Douglas Bates wrote:
> On Wed, Apr 6, 2011 at 3:44 PM, Christopher Desjardins
> wrote:
> > Hi,
> > I have longitudinal school suspension data on students. I would like to
> > figure out how many students (id_r) have no suspensions (sus), i.e. have
> a
> > code of
On Wed, Apr 6, 2011 at 3:44 PM, Christopher Desjardins
wrote:
> Hi,
> I have longitudinal school suspension data on students. I would like to
> figure out how many students (id_r) have no suspensions (sus), i.e. have a
> code of '0'. My data is in long format and the first 20 records look like
> t
Hi Chris,
Is this what you have in mind?
> sum(with(yourdata, tapply(sus, id_r, function(x) any(x==0
[1] 13
HTH,
Jorge
On Wed, Apr 6, 2011 at 4:44 PM, Christopher Desjardins <> wrote:
> Hi,
> I have longitudinal school suspension data on students. I would like to
> figure out how many stu
Hi,
I have longitudinal school suspension data on students. I would like to
figure out how many students (id_r) have no suspensions (sus), i.e. have a
code of '0'. My data is in long format and the first 20 records look like
the following:
> suslm[1:20,c(1,7)]
id_r sus
11 0
15 10
16
8 matches
Mail list logo