My current dataset data.df comes from about 420 students who took an 8-question survey under one of 3 instructors. escore is my outcome variable of interest.
'data.frame': 426 obs. of 10 variables:
$ ques01: int 1 1 1 1 1 1 0 0 0 1 ...
$ ques02: int 0 0 1 1 1 1 1 1 1 1 ...
$ ques03: int 0 0 1 1 0 0 1 1 0 1 ...
$ ques04: int 1 0 1 1 1 1 1 1 1 1 ...
$ ques05: int 0 0 0 0 1 0 0 0 0 0 ...
$ ques06: int 1 0 1 1 0 1 1 1 1 1 ...
$ ques07: int 0 0 1 1 0 1 1 0 0 1 ...
$ ques08: int 0 0 1 1 1 0 1 1 0 1 ...
$ inst : Factor w/ 3 levels "1","2","3": 1 1 1 1 1 1 1 1 1 1 ...
$ escore: int 3 1 5 5 3 3 4 4 2 5 ...
I’m wondering how I can generate escore histograms that are conditionally separated based upon the value of inst for a given observation. In my head, the pseudo-code might look like this:
par(mfrow=c(1,3))
hist(escore, data.df$inst = 1)
hist(escore, data.df$inst = 2)
hist(escore, data.df$inst = 3)
but of course that won’t work 🙁
Ideally, my histograms would look like this:
3 separate histograms of ~140 observations each, grouped according to their "inst" value http://terpconnect.umd.edu/~briandk/escoreHistogramsbyInstructor-1.png
As usual, I sense there’s got to be an easy way to do this. In whatever “conditional/grouping” sense I can extract these graphs from my data, I assume it’s got to be generalizable for all sorts of plots you’d want to make based on certain conditions.
Also, I’m really sorry if this question has been answered before. My primary difficulty is in figuring out how to ask it in a way that makes sense.
Thanks in advance for your help!
Use the lattice package:
if
Xis your data.frame object.