Thanks to those that replied. It was reproducible on my system but it
was nested within other code which would have been obvious had I left
the browse> portions in it. The reason for the behavior was obvious
when I used str(samples). Even though Effort looked like a vector in
samples, it was actually an array [,1:10] which was created from a
tapply. I was unaware that a dataframe could contain an array. Learned
something new. Next time I'll make sure my reproducible code is not
nested. Interesting difference between tapply and by behavior in that case.
Sebastian P. Luque wrote:
On Tue, 28 Oct 2008 18:04:57 -0700,
Jeff Laake <[EMAIL PROTECTED]> wrote:
Any insight into the behavior of "by" in the following case would be
appreciated. There is a note in the help details for "by" about
documenting behavior since v2.7 but I don't entirely understand what
it is saying. I'm using R2.7.2 Windows. I'm interested if the
following behavior was a change or whether it has always worked this
way. I looked at RSiteSearch and read through version changes but
found nothing.
Take a dataframe as follows:
samples
Region.Label Area Sample.Label Effort Label 1 1 10000 1 100 11 2 1
10000 2 100 12 3 1 10000 3 100 13 4 1 10000 4 100 14 5 1 10000 5 100
15 6 1 10000 6 100 16 7 1 10000 7 100 17 8 1 10000 8 100 18 9 1 10000
9 100 19 10 1 10000 10 100 110
I cannot reproduce your results (please provide reproducible code), but:
table(samples$Region.Label)
is simpler for this purpose.
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.