[R] boxplots instead of a scatterplot
Petr Pikal
petr.pikal at precheza.cz
Mon Apr 24 11:57:19 CEST 2006
Hi
On 24 Apr 2006 at 10:40, Michael Graber wrote:
Date sent: Mon, 24 Apr 2006 10:40:42 +0200
From: Michael Graber <michael_graber at gmx.de>
To: R-Mailingliste <r-help at stat.math.ethz.ch>
Subject: [R] boxplots instead of a scatterplot
> Dear R list,
>
> I am a newbie to R and programming itself, so my question may be easy
> to answer for you. I wanted to create a scatterplot and i used the
> following code:
>
> par(mar=c(10, 4.1,4.1,2.1))
> plot(q$location,q$points, , las=2, cex.axis=0.5,xlab="", ylab="" )
>
> #location are character strings, there are about 70 locations
location is probably a factor (not a character vector, try str(q) and
look what is stated at location variable) so that's why R used
boxplot automatically.
> loc<-sample(letters[1:3],10, replace=T)
> x<-rnorm(10)
> plot(loc,x)
Error in plot.window(xlim, ylim, log, asp, ...) :
need finite 'xlim' values
In addition: Warning messages:
1: NAs introduced by coercion
2: no finite arguments to min; returning Inf
3: no finite arguments to max; returning -Inf
> plot(as.factor(loc),x)
You can either:
plot(as.numeric(q$location) ,q$points, , las=2, cex.axis=0.5,xlab="",
ylab="" )
but you loose information about location names or to use stripchart
> stripchart(split(x,loc), vertical=T)
see ?stripchart
HTH
Petr
> #points are numeric, there are more than 4 points for every location
>
> my problem is that this code does not create a simple scatterplot with
> location on the x axis and points on the y axis. Instead of this i get
> "vertical boxplots" for every location.
>
> Thanks for any hint,
>
> Michael Graber
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
Petr Pikal
petr.pikal at precheza.cz
More information about the R-help
mailing list