Skip to content

2 functions in xyplot

3 messages · Markus Häge, Richard M. Heiberger, Paul Hiemstra

#
Hello,

after a long night I don't find any mistake anymore in my xyplot and it
doesn't work. I want to make a scatterplot with regression line.
Each of it alone is possible but both arguments together are not
working:

"unexpected symbol...

test<-lm(Magnetfeld~Spannung,data=Kalibrierung)

kalib<-xyplot(Magnetfeld~Spannung,data=Kalibrierung,xlab=list(label="Spannung (mV)",fontsize=20),ylab=list(label="Magnetfeld (T)",fontsize=20),scales=list(cex=1.5),
panel=function(){panel.xyplot(Kalibrierung$Spannung,Kalibrierung
$Magnetfeld)panel.abline(reg=test)})

I tried different arguments in "function()" and the "panel...()" but
without sucess. It's always a problem with two plots in one.

But I need it, it's very important for other cases as well

thanks

Markus
#
"Unexpected symbol" often means missing punctuation.

In this case, it looks like

panel=function(){panel.xyplot(Kalibrierung$Spannung,Kalibrierung
$Magnetfeld)panel.abline(reg=test)}

this argument is missing a semi-colon ";" before "panel.abline".

panel=function(){panel.xyplot(Kalibrierung$Spannung,Kalibrierung
$Magnetfeld); panel.abline(reg=test)}
#
RICHARD M. HEIBERGER wrote:
in addition to Richard:

I would try to write out the function over multiple lines:

panel=function(){
        panel.xyplot(Kalibrierung$Spannung,Kalibrierung$Magnetfeld)
        panel.abline(reg=test)}

solven the problem you had, as would the semicolon, but in my opinion it 
make the command more readable. You can also use '...' in the panel 
function:

panel=function(...){
        panel.xyplot(...)
        panel.abline(reg=test)}

I like this because I don't have think about what to pass on to 
panel.xyplot.

hope this helps,
Paul