Re: [R] Printing special characters

2023-01-16 Thread Rui Barradas

Às 10:15 de 16/01/2023, Martin Maechler escreveu:

Rui Barradas
 on Mon, 16 Jan 2023 08:46:43 + writes:


 > Às 08:31 de 16/01/2023, Jeff Newmiller escreveu:
 >> Use the Cairo PDF device?
 >>
 >> On January 16, 2023 12:18:48 AM PST, Dennis Fisher
 >>  wrote:
 >>> R 4.2.2 OS X
 >>>
 >>> Colleagues
 >>>
 >>> A file that I have read includes strings like this:
 >>> "EVENT ≥ 30 sec" When I include the string in a graphic
 >>> using: mtext(STRING, …)  it appears as: "EVENT ... 30
 >>> sec"
 >>>
 >>> Is there a simple work-around (short of reformatting all
 >>> the strings, then using plotmath)?
 >>>
 >>> Dennis
 >>>
 >>> Dennis Fisher MD P < (The "P Less Than" Company) Phone /
 >>> Fax: 1-866-PLessThan (1-866-753-7784) www.PLessThan.com
 >>>
 >>> __
 >>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and
 >>> more, see 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.
 >>
 > Hello,

 > I had no problems with

 > X11()
 > plot(1,1, pch = "")
 > text(1, 1, "EVENT ≥ 30 sec")
 > #dev.off()

Yes, for me too.
X11() *is*  by default the "X11cairo" device and that works, the
same as the "Cairo PDF" device that Jeff mentioned above.

Indeed,
   cairo_pdf("utf8-ex.pdf")  # works nicely

whereas  pdf("utf8-ex.pdf") does not {for me, with default font
families etc}, but rather shows the "..." instead.

*and* gives warnings during the plot
   conversion failure on 'EVENT ≥ 30 sec' in 'mbcsToSbcs': dot substituted for 

   conversion failure on 'EVENT ≥ 30 sec' in 'mbcsToSbcs': dot substituted for 
<89>
   conversion failure on 'EVENT ≥ 30 sec' in 'mbcsToSbcs': dot substituted for 


BTW, a simple one liner for testing is

plot(1, type="n", axes=FALSE, main = "EVENT ≥ 30 sec")

Note that help(pdf)  contains

See Also:

 pdfFonts, pdf.options, embedFonts, Devices, postscript.

 cairo_pdf and (on macOS only) quartz for other devices that
 can produce PDF.

 More details of font families and encodings and especially
 handling text in a non-Latin-1 encoding and embedding fonts can be
 found in

 Paul Murrell and Brian Ripley (2006).  “Non-standard fonts in
 PostScript and PDF graphics.” _R News_, *6*(2), 41-47.
 .

-
Martin

 > Hope this helps,
 > Rui Barradas

Hello,

I can confrim this behavior with cairo_pdf(), it works as expected 
printing "EVENT ≥ 30 sec".

But with pdf() I get an equal sign "EVENT = 30 sec" and no errors.
Full code:



cairo_pdf("~/Temp/cairo_pdf_utf8-ex.pdf")  # works
plot(1,1, pch = "")
text(1, 1, "EVENT ≥ 30 sec")
dev.off()
# null device
#   1

pdf("~/Temp/pdf_utf8-ex.pdf")  # prints "=", no warnings
plot(1,1, pch = "")
text(1, 1, "EVENT ≥ 30 sec")
dev.off()
# null device
#   1

sessionInfo()
# R version 4.2.1 (2022-06-23 ucrt)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
# Running under: Windows 10 x64 (build 22621)
#
# Matrix products: default
#
# locale:
# [1] LC_COLLATE=Portuguese_Portugal.utf8  LC_CTYPE=Portuguese_Portugal.utf8
# [3] LC_MONETARY=Portuguese_Portugal.utf8 LC_NUMERIC=C
# [5] LC_TIME=Portuguese_Portugal.utf8
#
# attached base packages:
# [1] stats graphics  grDevices utils datasets  methods   base
#
# loaded via a namespace (and not attached):
# [1] compiler_4.2.1
#


Also, nice trick to print the text as plot title, I will remember that 
one-liner.


Hope this helps,

Rui Barradas

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Printing special characters

2023-01-16 Thread Martin Maechler
> Rui Barradas 
> on Mon, 16 Jan 2023 08:46:43 + writes:

> Às 08:31 de 16/01/2023, Jeff Newmiller escreveu:
>> Use the Cairo PDF device?
>> 
>> On January 16, 2023 12:18:48 AM PST, Dennis Fisher
>>  wrote:
>>> R 4.2.2 OS X
>>> 
>>> Colleagues
>>> 
>>> A file that I have read includes strings like this:
>>> "EVENT ≥ 30 sec" When I include the string in a graphic
>>> using: mtext(STRING, …)  it appears as: "EVENT ... 30
>>> sec"
>>> 
>>> Is there a simple work-around (short of reformatting all
>>> the strings, then using plotmath)?
>>> 
>>> Dennis
>>> 
>>> Dennis Fisher MD P < (The "P Less Than" Company) Phone /
>>> Fax: 1-866-PLessThan (1-866-753-7784) www.PLessThan.com
>>> 
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and
>>> more, see 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.
>> 
> Hello,

> I had no problems with

> X11()
> plot(1,1, pch = "") 
> text(1, 1, "EVENT ≥ 30 sec")
> #dev.off()

Yes, for me too.
X11() *is*  by default the "X11cairo" device and that works, the
same as the "Cairo PDF" device that Jeff mentioned above.

Indeed,
  cairo_pdf("utf8-ex.pdf")  # works nicely

whereas  pdf("utf8-ex.pdf") does not {for me, with default font
families etc}, but rather shows the "..." instead.

*and* gives warnings during the plot
  conversion failure on 'EVENT ≥ 30 sec' in 'mbcsToSbcs': dot substituted for 

  conversion failure on 'EVENT ≥ 30 sec' in 'mbcsToSbcs': dot substituted for 
<89>
  conversion failure on 'EVENT ≥ 30 sec' in 'mbcsToSbcs': dot substituted for 


BTW, a simple one liner for testing is

   plot(1, type="n", axes=FALSE, main = "EVENT ≥ 30 sec")

Note that help(pdf)  contains

   See Also:

pdfFonts, pdf.options, embedFonts, Devices, postscript.

cairo_pdf and (on macOS only) quartz for other devices that
can produce PDF.

More details of font families and encodings and especially
handling text in a non-Latin-1 encoding and embedding fonts can be
found in

Paul Murrell and Brian Ripley (2006).  “Non-standard fonts in
PostScript and PDF graphics.” _R News_, *6*(2), 41-47.
.

-
Martin

> Hope this helps,
> Rui Barradas

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Printing special characters

2023-01-16 Thread PIKAL Petr
Hallo Dennis

Is the STRING in R still containing **≥** character?
Or it was converted during reading to R to ...?

What dput(STRING) result i?
 
Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of Dennis Fisher
> Sent: Monday, January 16, 2023 9:19 AM
> To: r-help@r-project.org
> Subject: [R] Printing special characters
> 
> R 4.2.2
> OS X
> 
> Colleagues
> 
> A file that I have read includes strings like this:
>   "EVENT ≥ 30 sec"
> When I include the string in a graphic using:
>   mtext(STRING, …)
> it appears as:
>   "EVENT ... 30 sec"
> 
> Is there a simple work-around (short of reformatting all the strings, then 
> using
> plotmath)?
> 
> Dennis
> 
> Dennis Fisher MD
> P < (The "P Less Than" Company)
> Phone / Fax: 1-866-PLessThan (1-866-753-7784) www.PLessThan.com
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] Printing special characters

2023-01-16 Thread Rui Barradas

Às 08:31 de 16/01/2023, Jeff Newmiller escreveu:

Use the Cairo PDF device?

On January 16, 2023 12:18:48 AM PST, Dennis Fisher  wrote:

R 4.2.2
OS X

Colleagues

A file that I have read includes strings like this:
"EVENT ≥ 30 sec"
When I include the string in a graphic using:
mtext(STRING, …)
it appears as:
"EVENT ... 30 sec"

Is there a simple work-around (short of reformatting all the strings, then 
using plotmath)?

Dennis

Dennis Fisher MD
P < (The "P Less Than" Company)
Phone / Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.



Hello,

I had no problems with


X11()
plot(1,1, pch = "")
text(1, 1, "EVENT ≥ 30 sec")
#dev.off()


Hope this helps,

Rui Barradas

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Printing special characters

2023-01-16 Thread Eric Berger
How about  just 'EVENT > 30 sec' or 'EVENT > 29 sec' ?


On Mon, Jan 16, 2023 at 10:19 AM Dennis Fisher  wrote:

> R 4.2.2
> OS X
>
> Colleagues
>
> A file that I have read includes strings like this:
> "EVENT ≥ 30 sec"
> When I include the string in a graphic using:
> mtext(STRING, …)
> it appears as:
> "EVENT ... 30 sec"
>
> Is there a simple work-around (short of reformatting all the strings, then
> using plotmath)?
>
> Dennis
>
> Dennis Fisher MD
> P < (The "P Less Than" Company)
> Phone / Fax: 1-866-PLessThan (1-866-753-7784)
> www.PLessThan.com
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Printing special characters

2023-01-16 Thread Jeff Newmiller
Use the Cairo PDF device?

On January 16, 2023 12:18:48 AM PST, Dennis Fisher  wrote:
>R 4.2.2
>OS X
>
>Colleagues
>
>A file that I have read includes strings like this:
>   "EVENT ≥ 30 sec"
>When I include the string in a graphic using:
>   mtext(STRING, …)
>it appears as:
>   "EVENT ... 30 sec"
>
>Is there a simple work-around (short of reformatting all the strings, then 
>using plotmath)?
>
>Dennis
>
>Dennis Fisher MD
>P < (The "P Less Than" Company)
>Phone / Fax: 1-866-PLessThan (1-866-753-7784)
>www.PLessThan.com
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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.

-- 
Sent from my phone. Please excuse my brevity.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Printing special characters

2023-01-16 Thread Dennis Fisher
R 4.2.2
OS X

Colleagues

A file that I have read includes strings like this:
"EVENT ≥ 30 sec"
When I include the string in a graphic using:
mtext(STRING, …)
it appears as:
"EVENT ... 30 sec"

Is there a simple work-around (short of reformatting all the strings, then 
using plotmath)?

Dennis

Dennis Fisher MD
P < (The "P Less Than" Company)
Phone / Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.