[R] Constructing titles from list of expressions

Winfried Theis theis at statistik.uni-dortmund.de
Wed Aug 7 14:58:05 CEST 2002


Hello!

I have the following problem:
I have a function to construct three surfaceplots with a marker for an optimum,
each of the plots has as title paste("Estimated ",pred.var.lab," for
",var.lab[1]," vs. ",var.lab[2],sep="") with different var.lab[1,2] each time.
My problem is now that I need to allow for plotmath expressions in the
variables pred.var.lab and var.lab[1,2] and get these evaluated correctly. 

I tested the usage of parse(), paste(), substitute() in different combinations,
but could not find a version, which worked. The problem seems to be the order
of evaluation...

I attach some data in test.Robj and my function theis.surfacesinopt.R and the
following line produces a plot which has the right labels at the plot axes but
the titles, etc. are unevaluated expressions.

surfacesinopt(gwRZ.step,gwRZ.coded.min.par,var.labs=c("f",expression(v[c]),
expression(ring(V))),pred.var.lab=expression(R[z]))

So if anyone has an idea how to get this working, I would be very pleased!

Winfried
---------------------------------------------------------------------
E-Mail: Winfried Theis <theis at statistik.uni-dortmund.de>
Date: 07-Aug-02

Dipl.-Math. Winfried Theis
SFB 475, Fachbereich Statistik, Universit"at Dortmund, 44221 Dortmund
Tel.: +49-231-755-5903 FAX: +49-231-755-4387
----------------------------------------------------------------------
-------------- next part --------------
RDA2
A
2
66561
66560
1026
1
5129
9
gwRZ.step
1811
14
1550
10
3.160970396668171
-252.4589750684217
0.001705753733731377
-5.797755919844388e-05
109.8794104646305
-0.3740786630940966
0.04108185624907657
0.2655689668011897
-0.1138539214221429
0.000136284019932226
1026
1
5129
5
names
1040
10
1033
11
(Intercept)
1033
6
I(f^2)
1033
7
I(vS^2)
1033
6
I(o^2)
1033
1
f
1033
2
vS
1033
1
o
1033
4
f:vS
1033
3
f:o
1033
4
vS:o
254
1550
22
-0.3241875523408745
-0.3011208856742085
0.006379114325799236
-0.1345354443103646
-0.1654647314828446
-0.1769971762566737
-0.08106700216284654
0.001897333562152987
0.3080613964501274
-0.4477981639022141
-0.2410583649025989
-0.05866976528924098
0.03726040880458353
0.2775787457249784
-0.005201323141723888
-0.1170542190075351
0.5205265395043763
0.3960791143257932
-0.1022208856742049
0.4454012994626008
0.6615791143257931
-0.4993875523408744
1026
767
1040
22
1033
4
WV\0401
1033
4
WV\0402
1033
4
WV\0403
1033
4
WV\0404
1033
4
WV\0405
1033
4
WV\0406
1033
4
WV\0407
1033
4
WV\0408
1033
4
WV\0409
1033
5
WV\04010
1033
5
WV\04011
1033
5
WV\04012
1033
5
WV\04013
1033
5
WV\04014
1033
5
WV\04015
1033
5
WV\04016
1033
5
WV\04017
1033
5
WV\04018
1033
5
WV\04019
1033
5
WV\04020
1033
5
WV\04021
1033
6
WV\04021a
254
1550
22
-18.08713150619729
0.8290512291162518
1.882427460114446
0.6954686782272577
1.533512907690056
-2.038644419208816
0.8058283964089259
-0.7329633191519374
-1.04746084519767
0.5782012149762413
-0.08216661883027604
0.3356453731559922
0.00433371387779182
0.02933208495615108
-0.5065517339369261
-0.04097737162786692
0.7361492998210378
0.4721559617054614
-0.02614403829453677
0.4297081348522593
0.7376559617054611
-0.4233107049612062
1026
767
1040
22
1033
11
(Intercept)
1033
6
I(f^2)
1033
7
I(vS^2)
1033
6
I(o^2)
1033
1
f
1033
2
vS
1033
1
o
1033
4
f:vS
1033
3
f:o
1033
4
vS:o
1033
0

1033
0

1033
0

1033
0

1033
0

1033
0

1033
0

1033
0

1033
0

1033
0

1033
0

1033
0

254
1037
1
10
1550
22
3.886854219007542
3.886854219007541
3.886854219007537
4.170468777643698
2.416264731482844
4.519830509590004
2.618067002162845
3.056869333104511
3.305271936883208
5.205498163902211
4.732858364902602
3.374803098622575
3.327306257862086
3.557287920941686
4.121434656475054
3.886854219007538
6.111206793828954
3.886854219007538
3.886854219007538
3.224165367204069
3.886854219007538
3.886854219007538
1026
767
1040
22
1033
4
WV\0401
1033
4
WV\0402
1033
4
WV\0403
1033
4
WV\0404
1033
4
WV\0405
1033
4
WV\0406
1033
4
WV\0407
1033
4
WV\0408
1033
4
WV\0409
1033
5
WV\04010
1033
5
WV\04011
1033
5
WV\04012
1033
5
WV\04013
1033
5
WV\04014
1033
5
WV\04015
1033
5
WV\04016
1033
5
WV\04017
1033
5
WV\04018
1033
5
WV\04019
1033
5
WV\04020
1033
5
WV\04021
1033
6
WV\04021a
254
1037
10
0
1
2
3
4
5
6
7
8
9
1555
5
1550
220
-4.69041575982343
0.2132007163556104
0.2132007163556104
0.2132007163556104
0.2132007163556104
0.2132007163556104
0.2132007163556104
0.2132007163556104
0.2132007163556104
0.2132007163556104
0.2132007163556104
0.2132007163556104
0.2132007163556104
0.2132007163556104
0.2132007163556104
0.2132007163556104
0.2132007163556104
0.2132007163556104
0.2132007163556104
0.2132007163556104
0.2132007163556104
0.2132007163556104
-0.1659400871596296
0.05930003728038074
0.01603419229691699
0.2673662433971773
0.3503510141610248
-0.3066637498565039
-0.3066637498565039
0.01603419229691699
0.2673662433971773
-0.3066637498565039
0.01603419229691699
0.2673662433971773
0.2673662433971773
0.01603419229691699
-0.3066637498565039
0.01603419229691699
0.01603419229691699
0.01603419229691699
0.01603419229691699
-0.4607783241322204
0.01603419229691699
0.01603419229691699
-39143.63680180702
23.41293789291487
13299.31321110811
-0.3101975468429001
0.009359918313717337
-0.3006082524939842
0.2736078651940737
0.01494475264001756
0.2640185708451577
-0.3006082524939842
0.3533080897965123
-0.3101975468429001
0.2640185708451577
0.01494475264001756
0.2736078651940737
0.01494475264001756
-0.4587639193790752
0.01494475264001756
0.01494475264001756
0.0229100081545769
0.01494475264001756
0.01494475264001756
-434929.5390063238
260.1621167534037
245.618222612686
-147771.338152989
-0.009206836006429417
0.2956917240376494
0.3050873520270487
0.4590044743169959
0.314519896224183
-0.2785278848566731
-0.009163898582984786
-0.2690953406595388
-0.2596997126701396
-0.3530609877671531
-0.2691322568672739
-0.01470037856542437
-0.02245145054083978
-0.01470037856542437
-0.01470037856542437
-0.02253543106759749
-0.01470037856542437
-0.01470037856542437
-0.8677269155673345
0.1583449257477383
-0.0002787602527545181
0.000278314340087362
0.01745649803920696
0.006728782592816668
0.09519978046480439
-0.216585975198633
0.2376257701619337
0.101531338187649
-0.08624567755187214
0.2439573278847783
0.332428325756766
-0.08251552562949618
0.1900023360596367
-0.1383782129499699
-0.2113637625073067
-0.1383782129499699
-0.1383782129499699
0.3974527230245541
-0.1383782129499699
-0.1383782129499699
-422.1374183841087
-5.951662053870351e-16
73.08554629333469
0.1214791867192892
1.165155571986074
7.553908280161528
0.1574972420164367
-0.1914912665935808
0.2418215252833476
0.08839030026573091
0.6081909372972452
0.1727145835326419
0.3104469531953226
-0.0944406974996987
0.2261226699284117
-0.1348784346221496
0.4134060841467976
-0.1348784346221496
-0.1348784346221496
-0.2320014128435806
-0.1348784346221496
-0.1348784346221496
-1407.124727947029
-4.079693885693428e-15
-3.567090579175913e-15
-243.6211172665207
3.884126720668327
3.318716930695771
24.96026977746597
0.4603794569267944
0.1557141947179466
0.1278999322847751
-0.1760119539352062
0.2003234556258289
0.2666364711558896
0.6172465305616485
0.1942129478148358
-0.1158425757904507
-0.2697936192301598
-0.1158425757904507
-0.1158425757904507
-0.1992620300970043
-0.1158425757904507
-0.1158425757904507
-78.09542240106011
14.25104331729644
13.49573764151901
0.04752194015093101
1.786638604346049
1.397473031829882
4.831204880595408e-16
-2.759973531473082
0.3848359324207057
0.2805457841354548
-0.3161314473009645
-0.4370640209472761
0.2348281542472329
0.1368278437644397
-0.4617756030431313
0.01704432056035159
-0.2663299963151941
0.01704432056035159
0.01704432056035159
0.03105283055406259
0.01704432056035159
0.01704432056035159
-260.3180746702004
47.50347772432148
-0.08362807582635584
-44.98641239228013
5.95551285508573
0.6139626321787167
4.617649908831202
-4.788107844239109e-16
9.200041879224676
0.5201250120869343
0.1898843864903249
-0.1549852991074885
-0.05234771239787212
0.2709890094192029
0.5719567254275598
-0.0920470434964091
0.0806570494444737
-0.0920470434964091
-0.0920470434964091
-0.1600034812659979
-0.0920470434964091
-0.0920470434964091
-126641.2255152326
9.054297497380299e-14
21925.66388800041
-21889.45679797108
699.118076455968
2564.857007811074
2246.424279971932
-3.573252804756066e-13
1.555422457499844e-12
4242.619312695505
0.145186559817048
0.2474244082715904
-0.4179784867286013
-0.4695774743142942
-0.6840398731214251
0.04271319897543584
0.1713139819573986
0.04271319897543584
0.04271319897543584
0.0759268860344612
0.04271319897543584
0.04271319897543584
1026
1
5129
3
dim
1037
2
22
10
1026
1
5129
8
dimnames
1043
2
1040
22
1033
4
WV\0401
1033
4
WV\0402
1033
4
WV\0403
1033
4
WV\0404
1033
4
WV\0405
1033
4
WV\0406
1033
4
WV\0407
1033
4
WV\0408
1033
4
WV\0409
1033
5
WV\04010
1033
5
WV\04011
1033
5
WV\04012
1033
5
WV\04013
1033
5
WV\04014
1033
5
WV\04015
1033
5
WV\04016
1033
5
WV\04017
1033
5
WV\04018
1033
5
WV\04019
1033
5
WV\04020
1033
5
WV\04021
1033
6
WV\04021a
1040
10
1033
11
(Intercept)
1033
6
I(f^2)
1033
7
I(vS^2)
1033
6
I(o^2)
1033
1
f
1033
2
vS
1033
1
o
1033
4
f:vS
1033
3
f:o
1033
4
vS:o
1026
1
5129
6
assign
1037
10
0
1
2
3
4
5
6
7
8
9
254
1038
10
1.21320071635561
1.016034192296917
1.014944752640017
1.305124268234784
1.598706838900933
1.019764872353756
1.083290671376893
1.348969912429107
1.437736978017322
1.10172019464236
1037
10
1
2
3
4
5
6
7
8
9
10
1038
1
1e-07
1037
1
10
1026
767
1040
5
5129
2
qr
5129
5
qraux
5129
5
pivot
5129
3
tol
5129
4
rank
254
1037
1
12
531
0
1026
767
16
0
254
6
1
5129
2
lm
1026
1
5129
7
formula
774
1026
1
5129
5
class
1040
1
1033
7
formula
1026
1
5129
12
.Environment
253
254
1
5129
1
~
2
1
5129
4
gwRZ
2
6
1
5129
1
+
2
6
3327
2
6
3327
2
6
3327
2
6
3327
2
6
3327
2
6
3327
2
6
3327
2
6
1
5129
1
I
2
6
1
5129
1
^
2
1
5129
1
f
2
1038
1
2
254
254
2
6
3583
2
6
3839
2
1
5129
2
vS
2
1038
1
2
254
254
254
2
6
3583
2
6
3839
2
1
5129
1
o
2
1038
1
2
254
254
254
2
4095
254
2
4351
254
2
4607
254
2
6
1
5129
1
:
2
4095
2
4351
254
254
2
6
4863
2
4095
2
4607
254
254
2
6
4863
2
4351
2
4607
254
254
254
1026
1
5129
4
data
1
5129
8
grob.erg
254
774
1026
1
5129
9
variables
6
1
5129
4
list
2
3071
2
6
3583
2
6
3839
2
4095
2
1038
1
2
254
254
2
6
3583
2
6
3839
2
4351
2
1038
1
2
254
254
2
6
3583
2
6
3839
2
4607
2
1038
1
2
254
254
2
4095
2
4351
2
4607
254
1026
1
5129
7
factors
1549
63
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
1
1
0
0
0
0
0
1
0
1
0
0
0
0
0
1
1
1026
1023
1037
2
7
9
1026
1279
1043
2
1040
7
5129
4
gwRZ
1033
6
I(f^2)
1033
7
I(vS^2)
1033
6
I(o^2)
5129
1
f
5129
2
vS
5129
1
o
1040
9
1033
6
I(f^2)
1033
7
I(vS^2)
1033
6
I(o^2)
1033
1
f
1033
2
vS
1033
1
o
1033
4
f:vS
1033
3
f:o
1033
4
vS:o
254
1026
1
5129
11
term.labels
1040
9
1033
6
I(f^2)
1033
7
I(vS^2)
1033
6
I(o^2)
1033
1
f
1033
2
vS
1033
1
o
1033
4
f:vS
1033
3
f:o
1033
4
vS:o
1026
1
5129
5
order
1037
9
1
1
1
1
1
1
2
2
2
1026
1
5129
9
intercept
1037
1
1
1026
1
5129
8
response
1037
1
1
1026
2303
1040
2
1033
5
terms
1033
7
formula
1026
2559
253
254
2815
2
3071
2
6
3327
2
6
3327
2
6
3327
2
6
3327
2
6
3327
2
6
3327
2
6
3327
2
6
3327
2
6
3583
2
6
3839
2
4095
2
1038
1
2
254
254
2
6
3583
2
6
3839
2
4351
2
1038
1
2
254
254
254
2
6
3583
2
6
3839
2
4607
2
1038
1
2
254
254
254
2
4095
254
2
4351
254
2
4607
254
2
6
4863
2
4095
2
4351
254
254
2
6
4863
2
4095
2
4607
254
254
2
6
4863
2
4351
2
4607
254
254
254
1811
7
1550
22
3.562666666666667
3.585733333333333
3.893233333333336
4.035933333333333
2.2508
4.34283333333333
2.536999999999999
3.058766666666664
3.613333333333335
4.757699999999997
4.491800000000003
3.316133333333334
3.36456666666667
3.834866666666664
4.11623333333333
3.769800000000003
6.63173333333333
4.282933333333331
3.784633333333333
3.66956666666667
4.548433333333331
3.387466666666664
1026
767
1040
22
1033
4
WV\0401
1033
4
WV\0402
1033
4
WV\0403
1033
4
WV\0404
1033
4
WV\0405
1033
4
WV\0406
1033
4
WV\0407
1033
4
WV\0408
1033
4
WV\0409
1033
5
WV\04010
1033
5
WV\04011
1033
5
WV\04012
1033
5
WV\04013
1033
5
WV\04014
1033
5
WV\04015
1033
5
WV\04016
1033
5
WV\04017
1033
5
WV\04018
1033
5
WV\04019
1033
5
WV\04020
1033
5
WV\04021
1033
6
WV\04021a
254
1806
22
0.034225
0.034225
0.034225
0.019321
0.0144
0.05336100000000001
0.05336100000000001
0.034225
0.019321
0.05336100000000001
0.034225
0.019321
0.019321
0.034225
0.05336100000000001
0.034225
0.034225
0.034225
0.034225
0.0625
0.034225
0.034225
1026
2303
1040
1
1033
4
AsIs
254
1806
22
8100
8100
8100
12368.331369
8100
12368.331369
4731.651369000001
8100
4731.651369000001
12368.331369
3600
12368.331369
4731.651369000001
8100
4731.651369000001
8100
14400
8100
8100
8100
8100
8100
1026
2303
1040
1
1033
4
AsIs
254
1806
22
90000
90000
90000
137426.645521
90000
137426.645521
137426.645521
160000
137426.645521
52573.44552099999
90000
52573.44552099999
52573.44552099999
40000
52573.44552099999
90000
90000
90000
90000
90000
90000
90000
1026
2303
1040
1
1033
4
AsIs
254
1038
22
0.185
0.185
0.185
0.139
0.12
0.231
0.231
0.185
0.139
0.231
0.185
0.139
0.139
0.185
0.231
0.185
0.185
0.185
0.185
0.25
0.185
0.185
1038
22
90
90
90
111.213
90
111.213
68.78700000000001
90
68.78700000000001
111.213
60
111.213
68.78700000000001
90
68.78700000000001
90
120
90
90
90
90
90
1038
22
300
300
300
370.711
300
370.711
370.711
400
370.711
229.289
300
229.289
229.289
200
229.289
300
300
300
300
300
300
300
1026
767
1040
7
1033
4
gwRZ
1033
6
I(f^2)
1033
7
I(vS^2)
1033
6
I(o^2)
1033
1
f
1033
2
vS
1033
1
o
1026
1
5129
5
terms
774
1026
5631
6
5887
2
3071
2
6
3583
2
6
3839
2
4095
2
1038
1
2
254
254
2
6
3583
2
6
3839
2
4351
2
1038
1
2
254
254
2
6
3583
2
6
3839
2
4607
2
1038
1
2
254
254
2
4095
2
4351
2
4607
254
1026
6143
1549
63
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
1
1
0
0
0
0
0
1
0
1
0
0
0
0
0
1
1
1026
1023
1037
2
7
9
1026
1279
1043
2
1040
7
5129
4
gwRZ
1033
6
I(f^2)
1033
7
I(vS^2)
1033
6
I(o^2)
5129
1
f
5129
2
vS
5129
1
o
1040
9
1033
6
I(f^2)
1033
7
I(vS^2)
1033
6
I(o^2)
1033
1
f
1033
2
vS
1033
1
o
1033
4
f:vS
1033
3
f:o
1033
4
vS:o
254
1026
6399
1040
9
1033
6
I(f^2)
1033
7
I(vS^2)
1033
6
I(o^2)
1033
1
f
1033
2
vS
1033
1
o
1033
4
f:vS
1033
3
f:o
1033
4
vS:o
1026
6655
1037
9
1
1
1
1
1
1
2
2
2
1026
6911
1037
1
1
1026
7167
1037
1
1
1026
2303
1040
2
1033
5
terms
1033
7
formula
1026
2559
253
254
2815
2
3071
2
6
3327
2
6
3327
2
6
3327
2
6
3327
2
6
3327
2
6
3327
2
6
3327
2
6
3327
2
6
3583
2
6
3839
2
4095
2
1038
1
2
254
254
2
6
3583
2
6
3839
2
4351
2
1038
1
2
254
254
254
2
6
3583
2
6
3839
2
4607
2
1038
1
2
254
254
254
2
4095
254
2
4351
254
2
4607
254
2
6
4863
2
4095
2
4351
254
254
2
6
4863
2
4095
2
4607
254
254
2
6
4863
2
4351
2
4607
254
254
254
1026
1
5129
9
row.names
1040
22
1033
4
WV\0401
1033
4
WV\0402
1033
4
WV\0403
1033
4
WV\0404
1033
4
WV\0405
1033
4
WV\0406
1033
4
WV\0407
1033
4
WV\0408
1033
4
WV\0409
1033
5
WV\04010
1033
5
WV\04011
1033
5
WV\04012
1033
5
WV\04013
1033
5
WV\04014
1033
5
WV\04015
1033
5
WV\04016
1033
5
WV\04017
1033
5
WV\04018
1033
5
WV\04019
1033
5
WV\04020
1033
5
WV\04021
1033
6
WV\04021a
1026
2303
1040
1
1033
10
data.frame
254
774
1026
2303
1040
1
1033
7
formula
1026
2559
253
254
2815
2
3071
2
6
3327
2
6
3327
2
6
3327
2
6
3327
2
6
3327
2
6
3327
2
6
3327
2
6
3327
2
6
3583
2
6
3839
2
4095
2
1038
1
2
254
254
2
6
3583
2
6
3839
2
4351
2
1038
1
2
254
254
254
2
6
3583
2
6
3839
2
4607
2
1038
1
2
254
254
254
2
4095
254
2
4351
254
2
4607
254
2
6
4863
2
4095
2
4351
254
254
2
6
4863
2
4095
2
4607
254
254
2
6
4863
2
4351
2
4607
254
254
254
1811
6
1808
2
1033
0

1033
8
-\040f:vS:o
1026
2303
1040
1
1033
4
AsIs
254
1038
2
NA
1
1038
2
NA
0.06008888888888708
1038
2
11
12
1038
2
1.991981143777952
2.052070032666839
1038
2
-30.84208072474399
-32.18825474834911
1026
767
1040
6
5129
4
Step
5129
2
Df
5129
8
Deviance
5129
9
Resid.\040Df
5129
10
Resid.\040Dev
5129
3
AIC
1026
7679
1040
2
1033
1
1
1033
1
2
1026
2303
1040
1
1033
10
data.frame
1026
1
5129
7
heading
1040
8
1033
47
Stepwise\040Model\040Path\040\nAnalysis\040of\040Deviance\040Table
1033
15
\nInitial\040Model:
1033
61
gwRZ\040~\040I(f^2)\040+\040I(vS^2)\040+\040I(o^2)\040+\040f\040+\040vS\040+\040
o\040+\040f:vS\040+\040f:o\040+\040
1033
17
\040\040\040\040vS:o\040+\040f:vS:o
1033
13
\nFinal\040Model:
1033
61
gwRZ\040~\040I(f^2)\040+\040I(vS^2)\040+\040I(o^2)\040+\040f\040+\040vS\040+\040
o\040+\040f:vS\040+\040f:o\040+\040
1033
8
\040\040\040\040vS:o
1033
1
\n
254
1026
767
1040
14
1033
12
coefficients
1033
9
residuals
1033
7
effects
1033
4
rank
1033
13
fitted.values
1033
6
assign
1033
2
qr
1033
11
df.residual
5129
7
xlevels
5129
4
call
5129
5
terms
5129
5
model
5129
7
formula
5129
5
anova
1026
2303
1040
1
1033
2
lm
254
1026
1
5129
18
gwRZ.coded.min.par
1038
3
0.1207451127917877
89.70226077469248
284.9345951599792
254
-------------- next part --------------
# Surfaceplots durch vorgegebenen Punkt "extremum"
"surfacesinopt" <-
function(x.lm, extremum, var.names=NULL, data=NULL, n=20,  conf.level=0.95, sing
leplot=T, extcol=2, titletext= NULL, var.labs=NULL, pred.var.lab=NULL, charcex=1
, chartype=10,maximize=FALSE)
{
  if (is.null(data)) data <- x.lm$model
  if ((!is.character(var.names)) | (length(var.names)<3)) {
    var.names <- names(x.lm$coef)[match(names(x.lm$coef), names(x.lm$model), nom
atch=0)]
    b <- NULL
    for (i in 1:length(var.names)) {if (charmatch("I(", var.names[i], nomatch=0)
!=1) {b<-c(b,i)}}
    var.names <- var.names[b]
  }
  var.names <- var.names[1:3]
  resp.name <- names(x.lm$model)[1]
  ranges <- t(apply(data[,var.names], 2, range))
  extremum <- as.list(extremum)
  names(extremum) <- var.names
  schaetz <- predict(x.lm, as.data.frame(extremum), interval="confidence", level
=conf.level)
  result <- list(prognose=schaetz[1], conf.interval=schaetz[-1], conf.level=conf
.level)
 # Graphen zeichnen
  old.pty <- par()$pty
  par(pty="s", ask=T)
  if (singleplot) layout(matrix(1:4,ncol=2))
  for (i in 3:1) {
    x <- seq(from=ranges[-i,][1,1], to=ranges[-i,][1,2], length=n)
    y <- seq(from=ranges[-i,][2,1], to=ranges[-i,][2,2], length=n)
    pred.dat <- matrix(NA, ncol=3, nrow=n^2)
    pred.dat[,i] <- rep(as.numeric(extremum[var.names[i]]),n^2)
    pred.dat[,-i] <- cbind(rep(x,times=rep(n,n)),rep(y,n))
    pred.dat <- as.data.frame(pred.dat)
    colnames(pred.dat) <- var.names
    pred.val <- matrix(predict(x.lm,pred.dat),ncol=n,byrow=T)
    if(is.null(titletext)){title <- paste("Estimated '",pred.var.lab,"' for '",v
ar.labs[-i][1],"' vs. '",var.labs[-i][2],"'", sep="")
    subtitle <- paste("third variable fixed at: ", var.labs[i],"=",signif(as.num
eric(extremum[i]),4), sep="")}else{
      title <- titletext[1]
      subtitle <- paste(titletext[2], var.labs[i],"=",signif(as.numeric(extremum
[i]),4), sep="")
    }
    contour(x, y, pred.val, xlab=var.labs[-i][1], ylab=var.labs[-i][2], main=tit
le, sub=subtitle)
    points(extremum[-i][1], extremum[-i][2], pch=chartype, col=extcol, cex=charc
ex)
  }
 # Textausgabe im 4. Graphen
  par(pty="m")
  plot.new()
  plot.window(c(0,10), c(10,0))
  ausgabe <- ifelse(maximize,"Maximum found at:", "Minimum found at:")
  ausgabe <- c(ausgabe, paste(var.labs, rep("= ",3)))
  ausgabe <- c(ausgabe,as.character(signif(as.numeric(extremum),4)))
  ausgabe <- c(ausgabe,paste("Predicted '", pred.var.lab,"' value: ", as.charact
er(signif(result$prognose,4)), sep=""))
  ausgabe <- c(ausgabe,paste(as.character(signif(conf.level*100,3)),"% confidenc
e interval:", sep=""))
  ausgabe <- c(ausgabe,paste("[",as.character(signif(result$conf.int[1],4)),", "
,as.character(signif(result$conf.int[2],4)),"]" , sep=""))
  text(c(1,rep(4,6),1,1,1), c(1,2,3,4,2,3,4,6,8,9), ausgabe, pos=c(4,2,2,2,4,4,4
,4,4,4))
  par(mfrow=c(1,1), pty=old.pty, ask=F)

 # result
}



More information about the R-help mailing list