I\'ve tough time with ggplot2 when used in function or S4. Here is my code without function:
rm(list=ls(all=TRUE)) library(nlme) data(Oats) Data <- Oats
Your version in the function is missing the following two lines at the very beginning compared to the original version:
Data$Env <- factor(Data$Block) Data$Gen <- factor(Data$Variety)
Have you experimented with using debug() to step through functions to find the source of errors?
debug()