Dear David,
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
details.
I hope this helps,
John
--------------------------------
John Fox
Senator William McMaster
Professor of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox
> -----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
> version.
>
> 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
> advance!
>
> --
> -dave----------------------------------------------------------------
> "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
> 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.