The mean problem can be solved with
president=c(Johnson,Johnson,Johnson,Johnson,Johnson,Johnson,Nix
on,Nixon,Nixon,Nixon,Nixon,Nixon)
approval=seq(1:12)
tapply(approval,president,mean)
For the other, I will try to come back. But I am sure somebody will be
faster than I.
Cheers,
Daniel
I found a solution. It's probably not the easiest one, but it works. It
assumes that your data frame is ordered from earliest to latest record for
each president, but it can be easily adjusted if you want to make it
dependent on a third column. The final vector index gives you the line
indices
2 matches
Mail list logo