[R] Question about scatterplot in package car
jfox at mcmaster.ca
Sat Jan 15 14:06:04 CET 2011
scatterplot() isn't intended to produce parallel boxplots with a factor on
the RHS of the formula (though that's a reasonable feature request) but
rather, as the name implies, to make scatterplots. For boxplots with
labelled outliers, use the car function Boxplot(), as in Boxplot(income ~
type, data=Prestige). Note that you can use a data argument with both
scatterplot() and Boxplot(), and doing so has the advantage of providing
point labels from the row names of the data frame. See ?Boxplot and
?scatterplot (and the book with which the package is associated) for
I hope this helps,
Senator William McMaster
Professor of Social Statistics
Department of Sociology
Hamilton, Ontario, Canada
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On Behalf Of David Perlman
> Sent: January-14-11 6:37 PM
> To: r-help at r-project.org
> Subject: [R] Question about scatterplot in package car
> I am getting an error message from scatterplot:
> > library(car)
> > scatterplot(Prestige$income~Prestige$type)
> Error in Summary.factor(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, :
> range not meaningful for factors
> In addition: Warning message:
> In Ops.factor(x[floor(d)], x[ceiling(d)]) : + not meaningful for factors
> The command does output the kind of graph that I want (boxplots).
> I just did install.packages("car") so I believe I have the latest
> More generally, the reason I am trying to do this is because I am trying
> to generate a boxplot with case number labels on the outlier points. I
> initially tried to do it with the base boxplot() but the returned values
> of the outliers do not include enough information to actually identify
> which cases those points came from. Scatterplot in car seems like it
> should be able to do the trick, but I haven't been able to figure out
> how to get it to work.
> The following command works as expected:
> scatterplot(Prestige$income~Prestige$prestige, id.n=4)
> but this command does not label anything:
> scatterplot(Prestige$income~Prestige$type, id.n=4) and also produces the
> same error.
> Furthermore, even if that did work, what I really want is for the points
> already identified as outliers to be labeled, but I have not been able
> to figure out how to do that. I am not sure if that is because I am
> confused, or because scatterplot() isn't working right!
> Any help with how to do this would be greatly appreciated. Thanks in
> "Pseudo-colored pictures of a person's brain lighting up are undoubtedly
> more persuasive than a pattern of squiggles produced by a polygraph.
> That could be a big problem if the goal is to get to the truth." -Dr.
> Steven Hyman, Harvard
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help