Would it really be so hard to

  provide commented, minimal, self-contained, _reproducible_ code

?

  -Peter Ehlers

On 2010-07-07 15:16, fsch wrote:

Hello-

I'm new to R, coding and stats. (Oh no.)
Anyway, I have about 12000 data points in a data.frame (dealing with
dimensions and geological stage information for fossil protists) and have
plotted them in a basic scatter plot. I also added a boxplot to overlay
these points. Each worked fine independently, but when I attempt to
superimpose them with add=true, I get a different scale for the boxplot,
which results in it being shifted back to the left relative to the scatter
plot. How do I force the boxplot to use the scatterplot's scale or something
to that effect?

My code. I'm not sure how to include the file I'm using as a dataframe:

#imports data

emdata<-read.table(file="#a file in my working directory", sep=",",
header=T)

#specifies a dataframe

foram<-data.frame(emdata)

#calculates actual dimensions in mm

foram$actual_l<-foram$length/foram$magnification
foram$actual_w<-foram$width/foram$magnification
foram$actual_h<-foram$height/foram$magnification

#takes logs of all dimensions

foram$logl<-log10(foram$actual_l)
foram$logw<-log10(foram$actual_w)
foram$logh<-log10(foram$actual_h)

#Generates scatterplot

plot(foram$stage,
        foram$logl,
        ylab="log max size",
        xlab="stage",
        cex=.1,
        xaxt="n",
        axes=FALSE
        )


axis(at=-3:1, side=2, pos=0)
        
axis(at=9:84, side=1,  pos=-3)

#adds a boxplot

boxplot(foram$logl~foram$stage, data=foram,
outline=F, axes=FALSE, add=TRUE, col="gray82", medlwd=1)



______________________________________________
R-help@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.

Reply via email to