[R] Question about scatterplot in package car

David Perlman dperlman at wisc.edu
Sat Jan 15 00:36:52 CET 2011

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!

"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

More information about the R-help mailing list