[R] Trouble with 'smooth' using xyplot in lattice
felix at nfrac.org
Mon Dec 22 09:11:59 CET 2008
The error message comes from panel.loess, which is the panel function
that draws the Loess smoothing line. It means one of your groups has
too few data points or is too clustered in its domain for the Loess
smoother to converge.
- give up on the pretty-looking smoother
- increase the span; or
- ignore the error, with eg
lattice.options = list(panel.error = "warning")
In any case I would recommend plotting the data points, not just the
smoothed lines. You can set type = c("p", "smooth")
2008/12/22 lost_river at excite.com <lost_river at excite.com>:
> I am fairly new to R am stumped on how to get the xyplot function in the lattice package to produce a scatter plot of count data versus time, such that the count data represent 8 different groups, and the plot produced has 8 unique "smoothed" lines for the different groups. This is the closest I can get to the desired plot:
> xyplot(masmean ~ mas, data = Pre96CR.masmeans, groups = behavior,
> type = 'smooth', span = 0.3, lwd =2,
> xlab = "Minutes After Sunrise", ylab = "Behaviors at Castle"
> key = simpleKey(levels(Pre96CR.masmeans$behavior), space = 'right'))
> This code produces a plot, but one level of the grouping factor ('behavior') is always absent from the plot and in the middle of the plot I receive an error message:
> Error using packet 1
> NA/NaN/Inf in foreign function call (arg 1)
> Otherwise, the plot is exactly what I want with smoothed lines produced for the 7 other levels of "behavior". Thanks in advance for any ideas/suggestions.
> Auto Insurance
> Click to get a free auto insurance quotes from top companies.
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Felix Andrews / 安福立
3358 543D AAC6 22C2 D336 80D9 360B 72DD 3E4C F5D8
More information about the R-help