[R] puzzled with plotmath

2011-01-20 Thread Claudia Beleites

Dear all,

I'm puzzled with matrix indices in plotmath.

I'm plotting matrix elements: Z [i, i], and I'd like to put that as label. I'll 
describe what I want and what I get in LaTeX-notation.


The output should look like Z_{i, i}, and my first try was
plot (1, 1, ylab = expression (Z[i, i]))

That, however, gives me Z_{i} (no comma, no second i) although the expression 
looks OK to me:

 a - expression (Z[i, i])
 a [[1]]
Z[i, i]
 str (as.list (a [[1]]))
List of 4
 $ : symbol [
 $ : symbol Z
 $ : symbol i
 $ : symbol i

I'm able to tweak the ouput looking as I want:
plot (1, 1, ylab = expression (Z[i][, ][i]))
which is, however, logically very far from what I want to express.

What am I missing?

I'm almost sure this has been discussed before, but I can't find it: can anyone 
point me to good search terms? Is it possible to search for the terms being 
close to each other in RSiteSearch and/or RSeek? I get lots of introductory 
documents as they point to plotmath and discuss matrices...


Thanks a lot for your help,

Claudia


--
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 0 40 5 58-37 68
email: cbelei...@units.it

__
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.


[R] puzzled with plotmath II

2011-01-20 Thread Claudia Beleites

sorry, I forgot my sessionInfo: please see below.


 Original Message 
Subject: puzzled with plotmath
Date: Thu, 20 Jan 2011 12:48:18 +0100
From: Claudia Beleites cbelei...@units.it
To: R Help r-help@r-project.org

Dear all,

I'm puzzled with matrix indices in plotmath.

I'm plotting matrix elements: Z [i, i], and I'd like to put that as label. I'll
describe what I want and what I get in LaTeX-notation.

The output should look like Z_{i, i}, and my first try was
plot (1, 1, ylab = expression (Z[i, i]))

That, however, gives me Z_{i} (no comma, no second i) although the expression
looks OK to me:

a - expression (Z[i, i])
a [[1]]

Z[i, i]

str (as.list (a [[1]]))

List of 4
 $ : symbol [
 $ : symbol Z
 $ : symbol i
 $ : symbol i

I'm able to tweak the ouput looking as I want:
plot (1, 1, ylab = expression (Z[i][, ][i]))
which is, however, logically very far from what I want to express.

What am I missing?

I'm almost sure this has been discussed before, but I can't find it: can anyone
point me to good search terms? Is it possible to search for the terms being
close to each other in RSiteSearch and/or RSeek? I get lots of introductory
documents as they point to plotmath and discuss matrices...

Thanks a lot for your help,

Claudia

 sessionInfo ()
R version 2.12.1 (2010-12-16)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.utf8   LC_NUMERIC=C  LC_TIME=en_US.utf8
 [4] LC_COLLATE=en_US.utf8 LC_MONETARY=C LC_MESSAGES=en_US.utf8
 [7] LC_PAPER=en_US.utf8   LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=CLC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

attached base packages:
[1] grid  stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] ggplot2_0.8.8 proto_0.3-8   reshape_0.8.3 plyr_1.2.1

loaded via a namespace (and not attached):
[1] digest_0.4.2 tools_2.12.1

--
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 0 40 5 58-37 68
email: cbelei...@units.it

__
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.


Re: [R] puzzled with plotmath II

2011-01-20 Thread Gerrit Eichner

Try


plot (1, 1, ylab = expression (Z[list(i,i)]))


Hth  --  Gerrit



 Original Message 
Subject: puzzled with plotmath
Date: Thu, 20 Jan 2011 12:48:18 +0100
From: Claudia Beleites cbelei...@units.it
To: R Help r-help@r-project.org

Dear all,

I'm puzzled with matrix indices in plotmath.

I'm plotting matrix elements: Z [i, i], and I'd like to put that as label. 
I'll

describe what I want and what I get in LaTeX-notation.

The output should look like Z_{i, i}, and my first try was
plot (1, 1, ylab = expression (Z[i, i]))

That, however, gives me Z_{i} (no comma, no second i) although the expression
looks OK to me:

a - expression (Z[i, i])
a [[1]]

Z[i, i]

str (as.list (a [[1]]))

List of 4
$ : symbol [
$ : symbol Z
$ : symbol i
$ : symbol i

I'm able to tweak the ouput looking as I want:
plot (1, 1, ylab = expression (Z[i][, ][i]))
which is, however, logically very far from what I want to express.

What am I missing?

I'm almost sure this has been discussed before, but I can't find it: can 
anyone

point me to good search terms? Is it possible to search for the terms being
close to each other in RSiteSearch and/or RSeek? I get lots of introductory
documents as they point to plotmath and discuss matrices...

Thanks a lot for your help,

Claudia


sessionInfo ()

R version 2.12.1 (2010-12-16)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
[1] LC_CTYPE=en_US.utf8   LC_NUMERIC=C  LC_TIME=en_US.utf8
[4] LC_COLLATE=en_US.utf8 LC_MONETARY=C 
LC_MESSAGES=en_US.utf8

[7] LC_PAPER=en_US.utf8   LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=CLC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

attached base packages:
[1] grid  stats graphics  grDevices utils datasets  methods 
base


other attached packages:
[1] ggplot2_0.8.8 proto_0.3-8   reshape_0.8.3 plyr_1.2.1

loaded via a namespace (and not attached):
[1] digest_0.4.2 tools_2.12.1

--
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 0 40 5 58-37 68
email: cbelei...@units.it

__
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.
__
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.


Re: [R] puzzled with plotmath for matrix indices

2011-01-20 Thread Claudia Beleites

Gerrit,

thanks  viele Grüße nach Oberhessen :-)


plot (1, 1, ylab = expression (Z[list(i,i)]))
though that cannot be evaluated, either (due to [ not knowing what to do with an 
index list)


for future searches: probably the easiest cheat is, of course,
plot (1, 1, ylab = expression (Z[i, i]))

Anyways, I put the how to into the R Wiki page on plotmath.

And I suggest that it should be mentioned in the plotmath help = email to 
r-devel.

Claudia

--
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 0 40 5 58-37 68
email: cbelei...@units.it

__
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.


Re: [R] puzzled with plotmath for matrix indices

2011-01-20 Thread Uwe Ligges



On 20.01.2011 14:08, Claudia Beleites wrote:

Gerrit,

thanks  viele Grüße nach Oberhessen :-)


plot (1, 1, ylab = expression (Z[list(i,i)]))

though that cannot be evaluated, either (due to [ not knowing what to do
with an index list)



Works for me with a recent R version.



for future searches: probably the easiest cheat is, of course,
plot (1, 1, ylab = expression (Z[i, i]))


which is less convenient since you could not replace i by a dynamically 
calculated number, for example.


Best,
Uwe Ligges



Anyways, I put the how to into the R Wiki page on plotmath.

And I suggest that it should be mentioned in the plotmath help = email
to r-devel.

Claudia



__
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.


Re: [R] puzzled with plotmath II

2011-01-20 Thread Peter Ehlers

On 2011-01-20 04:09, Gerrit Eichner wrote:

Try


plot (1, 1, ylab = expression (Z[list(i,i)]))


Hth  --  Gerrit



 Original Message 
Subject: puzzled with plotmath
Date: Thu, 20 Jan 2011 12:48:18 +0100
From: Claudia Beleitescbelei...@units.it
To: R Helpr-help@r-project.org

Dear all,

I'm puzzled with matrix indices in plotmath.

I'm plotting matrix elements: Z [i, i], and I'd like to put that as label.
I'll
describe what I want and what I get in LaTeX-notation.

The output should look like Z_{i, i}, and my first try was
plot (1, 1, ylab = expression (Z[i, i]))

That, however, gives me Z_{i} (no comma, no second i) although the expression
looks OK to me:

a- expression (Z[i, i])
a [[1]]

Z[i, i]

str (as.list (a [[1]]))

List of 4
$ : symbol [
$ : symbol Z
$ : symbol i
$ : symbol i

I'm able to tweak the ouput looking as I want:
plot (1, 1, ylab = expression (Z[i][, ][i]))
which is, however, logically very far from what I want to express.

What am I missing?

I'm almost sure this has been discussed before, but I can't find it: can
anyone
point me to good search terms? Is it possible to search for the terms being
close to each other in RSiteSearch and/or RSeek? I get lots of introductory
documents as they point to plotmath and discuss matrices...

[snip]

Claudia,
Look for 'comma-separated list' on the help page!!
It will lead you directly to Gerrit's solution.
I would put a space in front of the first 'i' with

 expression(Z[list(~i,i)])

or you can build it all up in pieces:

 expression(Z[~i*,~i])

Peter Ehlers

__
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.


Re: [R] puzzled with plotmath for matrix indices

2011-01-20 Thread Claudia Beleites

On 01/20/2011 02:11 PM, Uwe Ligges wrote:



On 20.01.2011 14:08, Claudia Beleites wrote:

Gerrit,

thanks  viele Grüße nach Oberhessen :-)


plot (1, 1, ylab = expression (Z[list(i,i)]))

though that cannot be evaluated, either (due to [ not knowing what to do
with an index list)



Works for me with a recent R version.
Sorry, my comment wasn't clear: sure it produces the desired output, what I 
meant is:

 Z
 [,1] [,2]
[1,]13
[2,]24
 i - 2
 eval (expression (Z[list(i,i)]))
Error in Z[list(i, i)] : invalid subscript type 'list'

whereas:
 eval (expression (Z[i,i]))
[1] 4

(and of course all the text-based solutions also lack the beauty of the 
expression actually meaning in R what the output looks like)



for future searches: probably the easiest cheat is, of course,
plot (1, 1, ylab = expression (Z[i, i]))


which is less convenient since you could not replace i by a dynamically
calculated number, for example.

good point.

Thanks, I learn a lot here :-)

Claudia

--
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 0 40 5 58-37 68
email: cbelei...@units.it

__
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.


Re: [R] puzzled with plotmath for matrix indices

2011-01-20 Thread Gerrit Eichner

Claudia,

Mittelhessen! ;-)


thanks  viele Grüße nach Oberhessen :-)



plot (1, 1, ylab = expression (Z[list(i,i)]))

though that cannot be evaluated, either (due to [ not knowing what to do
with an index list)


Something is missing; this last sentence of yours appears to be not 
complete, does it?



Regarding Uwe's remark and Peter's nice aesthetic suggestion:


plot( 1, 1, xlab = substitute( Z[list(~i, j)], list( i = 1, j = 2)))


should solve both problems.

This does work even in R as old as 2.7.1 (and, of course, for a more 
recent version as Uwe already stated).


 Best regards / Beste Grüße  --  Gerrit__
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.


Re: [R] puzzled with plotmath II

2011-01-20 Thread Claudia Beleites

Peter,


Look for 'comma-separated list' on the help page!!

Yes, seeing the solution I also understand why list is the solution.
The special meaning of list () in plotmath was only in my passive vocabulary - 
and after this discussion I think it is upgraded to active ;-)


I have to admit that my coming from matlab (as opposed to lisp) still catches me 
once in a while: though I was aware that I would somehow need to change the tree 
of the expression, I went astray because c() still feels to me the more basic 
function to put things together than list ().
A second aspect that put me a bit off the track is that both create expressions 
that do have a meaning but don't mean in R what I want to express:

Z [c(a, b)] is meaningful, but not the same as Z [a, b]
Z [list (a, b)] is syntactically correct, but `[.matrix` doesn't accept lists 
for parameter i)


Anyways, thanks a lot for the patience everyone:
problem is solved, solutions (including bquote) are to be found in the Wiki, and 
instead of creating more fuss by unclear emails I'll fetch a coffee before I go 
on plotting my confusion matrix elements...


Claudia

--
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 0 40 5 58-37 68
email: cbelei...@units.it

__
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.


Re: [R] puzzled with plotmath II

2011-01-20 Thread S Ellison
expression(Z[i][i])

also works as expected, though without the comma.

S Ellison

 Gerrit Eichner gerrit.eich...@math.uni-giessen.de 01/20/11 12:09 PM 
Try

 plot (1, 1, ylab = expression (Z[list(i,i)]))

Hth  --  Gerrit


  Original Message 
 Subject: puzzled with plotmath
 Date: Thu, 20 Jan 2011 12:48:18 +0100
 From: Claudia Beleites cbelei...@units.it
 To: R Help r-help@r-project.org

 Dear all,

 I'm puzzled with matrix indices in plotmath.

 I'm plotting matrix elements: Z [i, i], and I'd like to put that as label. 
 I'll
 describe what I want and what I get in LaTeX-notation.

 The output should look like Z_{i, i}, and my first try was
 plot (1, 1, ylab = expression (Z[i, i]))

 That, however, gives me Z_{i} (no comma, no second i) although the expression
 looks OK to me:
 a - expression (Z[i, i])
 a [[1]]
 Z[i, i]
 str (as.list (a [[1]]))
 List of 4
 $ : symbol [
 $ : symbol Z
 $ : symbol i
 $ : symbol i

 I'm able to tweak the ouput looking as I want:
 plot (1, 1, ylab = expression (Z[i][, ][i]))
 which is, however, logically very far from what I want to express.

 What am I missing?

 I'm almost sure this has been discussed before, but I can't find it: can 
 anyone
 point me to good search terms? Is it possible to search for the terms being
 close to each other in RSiteSearch and/or RSeek? I get lots of introductory
 documents as they point to plotmath and discuss matrices...

 Thanks a lot for your help,

 Claudia

 sessionInfo ()
 R version 2.12.1 (2010-12-16)
 Platform: x86_64-pc-linux-gnu (64-bit)

 locale:
 [1] LC_CTYPE=en_US.utf8   LC_NUMERIC=C  LC_TIME=en_US.utf8
 [4] LC_COLLATE=en_US.utf8 LC_MONETARY=C 
 LC_MESSAGES=en_US.utf8
 [7] LC_PAPER=en_US.utf8   LC_NAME=C LC_ADDRESS=C
 [10] LC_TELEPHONE=CLC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

 attached base packages:
 [1] grid  stats graphics  grDevices utils datasets  methods 
 base

 other attached packages:
 [1] ggplot2_0.8.8 proto_0.3-8   reshape_0.8.3 plyr_1.2.1

 loaded via a namespace (and not attached):
 [1] digest_0.4.2 tools_2.12.1

 -- 
 Claudia Beleites
 Dipartimento dei Materiali e delle Risorse Naturali
 Università degli Studi di Trieste
 Via Alfonso Valerio 6/a
 I-34127 Trieste

 phone: +39 0 40 5 58-37 68
 email: cbelei...@units.it

 __
 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.

***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
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.