Re: [R] single character in R, and how to manipulate it

2023-03-30 Thread Paul Murrell

Hi

From R 4.2.0, mirroring is possible (if a little awkward) ...

library(grid)
grid.newpage()
grid.define(textGrob("R"), name="r")
grid.use("r",
 transform=function(group, device)
 viewportTransform(group, flip=groupFlip(flipX=TRUE)))

... although only on pdf() and Cairo-based devices.

Paul

On 31/03/23 13:14, Jim Lemon wrote:

Also see the "arctext" function in the plotrix package.

Jim

On Fri, Mar 31, 2023 at 11:12 AM Jim Lemon  wrote:
 >
 > Hi Jinsong,
 > Maybe "srt" will do what you want. As you noted non-orthogonal
 > rotations may not work on some devices. You may be able to download
 > mirror fonts from places like fontmirror.com, but it more complicated.
 >
 > Jim
 >
 > On Thu, Mar 30, 2023 at 7:25 PM Jinsong Zhao  wrote:
 > >
 > > Hi there,
 > >
 > >
 > > I just noticed that "crt" is a graphical parameter, which is stated 
as follows in the help page of "par":
 > > A numerical value specifying (in degrees) how single characters 
should be rotated. It is unwise to expect values other than multiples of 
90 to work...

 > >
 > >
 > > However, I did not find any code example to demo the usage of 
"crt", and even know how to present a *single character* in R. It seems 
that R treats "A" as a string. If I wanted to rotated it in a plot, I 
could use "text" function with "srt" argument. But how to use "crt"?

 > >
 > >
 > > Another related question, how to mirror a character in R plot? For 
example, the mirror of "R" is something like "Я".

 > >
 > >
 > > Any hint? Thanks in advance.
 > >
 > >
 > > Best,
 > > Jinsong
 > > [[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.

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


--
Dr Paul Murrell
Te Kura Tatauranga | Department of Statistics
Waipapa Taumata Rau | The University of Auckland
Private Bag 92019, Auckland 1142, New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
www.stat.auckland.ac.nz/~paul/

__
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] single character in R, and how to manipulate it

2023-03-30 Thread Jim Lemon
Also see the "arctext" function in the plotrix package.

Jim

On Fri, Mar 31, 2023 at 11:12 AM Jim Lemon  wrote:
>
> Hi Jinsong,
> Maybe "srt" will do what you want. As you noted non-orthogonal
> rotations may not work on some devices. You may be able to download
> mirror fonts from places like fontmirror.com, but it more complicated.
>
> Jim
>
> On Thu, Mar 30, 2023 at 7:25 PM Jinsong Zhao  wrote:
> >
> > Hi there,
> >
> >
> > I just noticed that "crt" is a graphical parameter, which is stated as 
> > follows in the help page of "par":
> > A numerical value specifying (in degrees) how single characters should be 
> > rotated. It is unwise to expect values other than multiples of 90 to work...
> >
> >
> > However, I did not find any code example to demo the usage of "crt", and 
> > even know how to present a *single character* in R. It seems that R treats 
> > "A" as a string. If I wanted to rotated it in a plot, I could use "text" 
> > function with "srt" argument. But how to use "crt"?
> >
> >
> > Another related question, how to mirror a character in R plot? For example, 
> > the mirror of "R" is something like "Я".
> >
> >
> > Any hint? Thanks in advance.
> >
> >
> > Best,
> > Jinsong
> > [[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.

__
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] single character in R, and how to manipulate it

2023-03-30 Thread Jim Lemon
Hi Jinsong,
Maybe "srt" will do what you want. As you noted non-orthogonal
rotations may not work on some devices. You may be able to download
mirror fonts from places like fontmirror.com, but it more complicated.

Jim

On Thu, Mar 30, 2023 at 7:25 PM Jinsong Zhao  wrote:
>
> Hi there,
>
>
> I just noticed that "crt" is a graphical parameter, which is stated as 
> follows in the help page of "par":
> A numerical value specifying (in degrees) how single characters should be 
> rotated. It is unwise to expect values other than multiples of 90 to work...
>
>
> However, I did not find any code example to demo the usage of "crt", and even 
> know how to present a *single character* in R. It seems that R treats "A" as 
> a string. If I wanted to rotated it in a plot, I could use "text" function 
> with "srt" argument. But how to use "crt"?
>
>
> Another related question, how to mirror a character in R plot? For example, 
> the mirror of "R" is something like "Я".
>
>
> Any hint? Thanks in advance.
>
>
> Best,
> Jinsong
> [[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.

__
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] single character in R, and how to manipulate it

2023-03-30 Thread Rui Barradas

Às 09:25 de 30/03/2023, Jinsong Zhao escreveu:

Hi there,


I just noticed that "crt" is a graphical parameter, which is stated as follows in the 
help page of "par":
A numerical value specifying (in degrees) how single characters should be 
rotated. It is unwise to expect values other than multiples of 90 to work...


However, I did not find any code example to demo the usage of "crt", and even know how to present a *single character* 
in R. It seems that R treats "A" as a string. If I wanted to rotated it in a plot, I could use "text" 
function with "srt" argument. But how to use "crt"?


Another related question, how to mirror a character in R plot? For example, the mirror of 
"R" is something like "Я".


Any hint? Thanks in advance.


Best,
Jinsong
[[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.

Hello,

You are right, according to this not very old R-Help thread [1] there 
are no user-level functions that use crt. Characters are treated as 
character *strings* and rotated with srt.



txt <- "Rui Barradas"
plot(1, type = "n")
text(1, 1, txt, srt = 180)


As for how to mirror characters, I don't know the answer.

[1] https://stat.ethz.ch/pipermail/r-help/2017-May/446635.html

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.


[R] single character in R, and how to manipulate it

2023-03-30 Thread Jinsong Zhao
Hi there,


I just noticed that "crt" is a graphical parameter, which is stated as follows 
in the help page of "par":
A numerical value specifying (in degrees) how single characters should be 
rotated. It is unwise to expect values other than multiples of 90 to work...


However, I did not find any code example to demo the usage of "crt", and even 
know how to present a *single character* in R. It seems that R treats "A" as a 
string. If I wanted to rotated it in a plot, I could use "text" function with 
"srt" argument. But how to use "crt"?


Another related question, how to mirror a character in R plot? For example, the 
mirror of "R" is something like "Я".


Any hint? Thanks in advance.


Best,
Jinsong
[[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.