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.


[R] seqMK function

2023-03-30 Thread Nick Wray
Hello does anyone know how to set the confidence level within the seqMK()
function in the pheno package.  It seems to be set automatically at 0.05
and there seems to be neither an input function to set a different level,
as there are with some changepoint functions, nor an output to give one the
p-value of the changepoint identification which you get with functions ie
func$p_value etc ...
Thanks Nick Wray

[[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] Problems with foreign

2023-03-30 Thread David Winsemius



On 3/30/23 10:36, José Oscar Delgado Bautista wrote:

  Good day
My name is José Oscar, I'm from Mexico and I have some questions about
foreign in your write.foreig( ) function. We know that this function
generates the inputs to be able to run them or execute them in another
program like SPSS, SAS or Stata. In these cases, when creating an example
file, a matrix and using the function to execute the .sps file directly
from SPSS, I don't care or work based on the SPSS environment. With Stata
the problem does not arise, but this same problem also arises with SAS, in
that sense or question, how could I solve this? Do you have any guides or
tutorials on the correct use of the function?


I don't really understand the question. Not sure what the problem you 
are seeing when you attempt to get SAS-style output. I went to the help 
page for `write.foreign`:


?write.foreign

...  and the Arguments section clearly shows that although "SPSS" is the 
default value, that any of the other recognized values for the format of 
the output would be accepted.


Perhaps you are so inexperienced with R that you don't even know how to 
access the help system?



This is the code:
x<- matrix(data = sample(1:100,
  100),
nrow = 10, ncol = 10)

x2<- as.data.frame(x)

write.foreign(x2, "x2_spss.txt", "x2_spss.sps", package = "SPSS")


When I changed the "package" argument to "SAS", ...  I get SAS code:

* Written by R;
*  write.foreign(esoph, datafile, codefile, package = "SAS") ;

PROC FORMAT;
value agegp
 1 = "25-34"
 2 = "35-44"
 3 = "45-54"
 4 = "55-64"
 5 = "65-74"
 6 = "75+"
;

value alcgp
 1 = "0-39g/day"
 2 = "40-79"
 3 = "80-119"
 4 = "120+"
;

value tobgp
 1 = "0-9g/day"
 2 = "10-19"
 3 = "20-29"
 4 = "30+"
;

DATA  rdata ;
INFILE  "/tmp/RtmpFcHZ9L/file6a7222461f1c"
 DSD
 LRECL= 15 ;
INPUT
 agegp
 alcgp
 tobgp
 ncases
 ncontrols
;
FORMAT agegp agegp. ;
FORMAT alcgp alcgp. ;
FORMAT tobgp tobgp. ;
RUN;

--

David.



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


[R] Problems with foreign

2023-03-30 Thread José Oscar Delgado Bautista
 Good day
My name is José Oscar, I'm from Mexico and I have some questions about
foreign in your write.foreig( ) function. We know that this function
generates the inputs to be able to run them or execute them in another
program like SPSS, SAS or Stata. In these cases, when creating an example
file, a matrix and using the function to execute the .sps file directly
from SPSS, I don't care or work based on the SPSS environment. With Stata
the problem does not arise, but this same problem also arises with SAS, in
that sense or question, how could I solve this? Do you have any guides or
tutorials on the correct use of the function?

This is the code:
x<- matrix(data = sample(1:100,
 100),
   nrow = 10, ncol = 10)

x2<- as.data.frame(x)

write.foreign(x2, "x2_spss.txt", "x2_spss.sps", package = "SPSS")

[[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] 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.