jennybc / STAT545A_2013

UBC grad course in data analysis with R
http://www.stat.ubc.ca/~jenny/STAT545A/current.html
Other
23 stars 51 forks source link

Understand errors when using trimmed mean inside `plyr` functions called from `knitr` #121

Open jennybc opened 11 years ago

jennybc commented 11 years ago

In homework 4, I get intermittent problems around the trimmed mean. Here's an example: foo

The user-defined function myTrimMean() is not being found here. But this code works fine in the Console and when I compile via RStudio's Knit HTML button. It also worked fine in this very compilation, run by fileherd, in the previous R chunks. Why does this happen?

jennybc commented 11 years ago

If I define the function myTrimMean() in my active R session, then compile via fileherd(), I get a new error:

foobar

Now the problem is not being able to see jTrim.

jennybc commented 11 years ago

And then, after compiling successfully with RStudio and knit2html() ... it compiles successfully with fileherd(). I am mystified. Need to strip an example down to just taking a trimmed mean in these various ways and get to the bottom of this.

jennybc commented 11 years ago

Is there something funky about scoping and ddply() that's only exposed when using knitr?

BTW happens with hw03 as well, which has some trimmed mean stuff.

Is this thread on the knitr Google Group relevant? https://groups.google.com/forum/#!searchin/knitr/plyr/knitr/qZKxMrhPzEY/WC0JFrXepwwJ