Re: [R] 2 KM curves on the same plot

2020-09-30 Thread Jim Lemon
Hi John,
Hmmm, this works:

plot(1:10)
xylim<-par("usr")
clip(5,xylim[2],xylim[3],xylim[4])
lines(10:1)

so I suspect that there is a "lines" method that resets the clipping
region out of sight. Fortunately Mark Schwartz provided a way to get
your plot so I will give the wall against which I have been banging my
head a break.

Jim

On Wed, Sep 30, 2020 at 1:57 PM array chip  wrote:
>
> Jim,
>
> I tried a few things, I found that clip() works if I just do some regular 
> graphing tasks. But as long as I run lines(fit) with "fit" object is a 
> survfit object, this would reset to default plot region. See the ovarian 
> example below:
>
> library(survival)
> ovarian1<-ovarian
> ovarian1$fustat[ovarian$futime>450]<-0
> ovarian1$futime[ovarian$futime>450]<-450
> ovarian2<-subset(ovarian,futime>450)
>
> fit1 <- survfit(Surv(futime, fustat) ~ rx, data = ovarian1)
> fit2 <- survfit(Surv(futime, fustat) ~ rx, data = ovarian2)
>
> plot(fit1, xlim=c(0,1200), col = 1:2)
> abline(v=450)
> xylim<-par("usr")
> points(-1,-1)
> clip(450,xylim[2],xylim[3],xylim[4])
> abline(h=0.5,col=2)  ### YES, clipping() works!
>
> lines(fit2, col = 3:4,lty=2)  ### clipping does not work! reset to default 
> plot region
> abline(h=0.4,col=2)   ### NO, clipping() does not work!
>
> So disappointed with this, otherwise this would be such a simple method to do 
> what I want.
>
> Thanks,
>
> John
>
> On Tuesday, September 29, 2020, 07:58:53 PM PDT, Jim Lemon 
>  wrote:
>
> Hi John,
> I should have remembered this. For some reason, the clip() function
> doesn't operate until you have issued a graphics command. Try:
>
> points(-1,-1)
>
> before calling lines()
>
> Jim
>
> On Wed, Sep 30, 2020 at 12:26 PM array chip  wrote:
> >
> > Hi Jim,
> >
> > I tried the clip() function below, surprisingly it did not work! I read the 
> > R help file and feel your script should work. To have a workable example, I 
> > used the ovarian dataset in the survival package as an example:
> >
> > ovarian1<-ovarian
> > ovarian1$fustat[ovarian$futime>450]<-0
> > ovarian1$futime[ovarian$futime>450]<-450
> >
> > ovarian2<-subset(ovarian,futime>450)
> >
> > fit1 <- survfit(Surv(futime, fustat) ~ rx, data = ovarian1)
> > fit2 <- survfit(Surv(futime, fustat) ~ rx, data = ovarian2)
> >
> > plot(fit1, xlim=c(0,1200), col = 1:2)
> > abline(v=450)
> > xylim<-par("usr")
> > clip(450,xylim[2],xylim[3],xylim[4])
> > lines(fit2, col = 3:4,lty=2)
> >
> > I can still see that the extra horizontal line on the top.
> >
> > Can you or anyone have any suggestion what went wrong?
> >
> > Thanks,
> >
> > John
> >
> >
> > On Tuesday, September 29, 2020, 01:35:48 AM PDT, Jim Lemon 
> >  wrote:
> >
> >
> >
> >
> >
> > Hi John,
> > Perhaps the most direct way would be:
> >
> > plot(fit1, col=1:2)
> > xylim<-par("usr")
> > clip(4,xylim[2],xylim[3],xylim[4])
> > lines(fit2,col=1:2)
> >
> > Remember that the new clipping rectangle will persist until you or
> > something else resets it.
> >
> > Jim
> >
> > On Tue, Sep 29, 2020 at 10:34 AM array chip via R-help
> >  wrote:
> > >
> > > Hello,
> > >
> > > Can anyone suggest a simple way to generate a Kaplan-Meier plot with 2 
> > > survfit objects, just like this one:
> > >
> > > https://drive.google.com/file/d/1fEcpdIdE2xYtA6LBQN9ck3JkL6-goabX/view?usp=sharing
> > >
> > > Suppose I have 2 survfit objects: fit1 is for the curve on the left 
> > > (survtime has been truncated to the cutoff line: year 5), fit2 is for the 
> > > curve on the right (minimum survival time is at the cutoff line: year 5), 
> > > but if I do the following:
> > >
> > > plot(fit1, col=1:2)
> > > lines(fit2,col=1:2)
> > >
> > > Then I will have an horizontal line on the top that connect from 0 to 4 
> > > years, which I do not want that to be drawn (see blue arrow below):
> > >
> > > https://drive.google.com/file/d/178mQGlhnaOg9PA-oE-W_W5CtrGD03ljH/view?usp=sharing
> > >
> > > Can anyone have a strategy to make this kind of plot happen?
> > >
> > > Thanks,
> > >
> > > John
> >
> > >
> > > __
> > > 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] How to decrease size of points?

2020-09-30 Thread Medic
The code works as I want, but the points are too big. How to decrease
them? (Where to insert: size = 0.8?)
p1 <- p + geom_point(aes(size = Stage), alpha = 1/3) + xlab ("X") +
ylab("Y") + geom_smooth()

__
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] How to decrease size of points?

2020-09-30 Thread Rui Barradas

Hello,

Your example is not reproducible but here it goes.

Data:

df1 <- iris[c(1, 2, 5)]

Use scale_size_manual.

1. If Stage is a factor or character



df1$Stage <- "a"

p <- ggplot(df1, aes(Sepal.Length, Sepal.Width, color = Species))
p1 <- p +
  geom_point(aes(size = Stage), alpha = 1/3) +
  xlab ("X") +
  ylab("Y") +
  geom_smooth(method = 'loess', formula = y ~ x)



2. If Stage is numeric, coerce to factor manually


df1$Stage <- 5

p <- ggplot(df1, aes(Sepal.Length, Sepal.Width, color = Species))
p1 <- p +
  geom_point(aes(size = factor(Stage)), alpha = 1/3) +
  xlab ("X") +
  ylab("Y") +
  geom_smooth(method = 'loess', formula = y ~ x)


Then add the scale_size


p1 + scale_size_manual(values = 0.8)


Hope this helps,

Rui Barradas

Às 16:05 de 30/09/20, Medic escreveu:

The code works as I want, but the points are too big. How to decrease
them? (Where to insert: size = 0.8?)
p1 <- p + geom_point(aes(size = Stage), alpha = 1/3) + xlab ("X") +
ylab("Y") + geom_smooth()

__
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] [R-pkgs] New version of package brant on CRAN

2020-09-30 Thread kontakt
Dear R community

 

The new version of the package brant (0.3-0) is now available on CRAN. It
contains the function brant() to test the parallel regression assumption for
ordinal logistic regression models.

 

I this version I fixed a bug which led in some situations to an error
message and I added support for interaction terms. 

 

Let me know if you have any questions, still get an error message in any
situation or have suggestions.

 

Best,

 

Benjamin Schlegel

Assistent Lehrstuhl f�r Methoden

 

Unversit�t Z�rich

Institut f�r Politikwissenschaften

Affolternstrasse 56

8050 Z�rich

 

+41 44 634 62 08

kont...@benjaminschlegel.ch  


[[alternative HTML version deleted]]

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages
__
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] 2 KM curves on the same plot

2020-09-30 Thread array chip via R-help
Thank you Jim for helping! Yes, I will try Mark's method.

John


On Wednesday, September 30, 2020, 01:47:55 AM PDT, Jim Lemon 
 wrote: 

Hi John,
Hmmm, this works:

plot(1:10)
xylim<-par("usr")
clip(5,xylim[2],xylim[3],xylim[4])
lines(10:1)

so I suspect that there is a "lines" method that resets the clipping
region out of sight. Fortunately Mark Schwartz provided a way to get
your plot so I will give the wall against which I have been banging my
head a break.

Jim

On Wed, Sep 30, 2020 at 1:57 PM array chip  wrote:
>
> Jim,
>
> I tried a few things, I found that clip() works if I just do some regular 
> graphing tasks. But as long as I run lines(fit) with "fit" object is a 
> survfit object, this would reset to default plot region. See the ovarian 
> example below:
>
> library(survival)
> ovarian1<-ovarian
> ovarian1$fustat[ovarian$futime>450]<-0
> ovarian1$futime[ovarian$futime>450]<-450
> ovarian2<-subset(ovarian,futime>450)
>
> fit1 <- survfit(Surv(futime, fustat) ~ rx, data = ovarian1)
> fit2 <- survfit(Surv(futime, fustat) ~ rx, data = ovarian2)
>
> plot(fit1, xlim=c(0,1200), col = 1:2)
> abline(v=450)
> xylim<-par("usr")
> points(-1,-1)
> clip(450,xylim[2],xylim[3],xylim[4])
> abline(h=0.5,col=2)      ### YES, clipping() works!
>
> lines(fit2, col = 3:4,lty=2)  ### clipping does not work! reset to default 
> plot region
> abline(h=0.4,col=2)      ### NO, clipping() does not work!
>
> So disappointed with this, otherwise this would be such a simple method to do 
> what I want.
>
> Thanks,
>
> John
>
> On Tuesday, September 29, 2020, 07:58:53 PM PDT, Jim Lemon 
>  wrote:
>
> Hi John,
> I should have remembered this. For some reason, the clip() function
> doesn't operate until you have issued a graphics command. Try:
>
> points(-1,-1)
>
> before calling lines()
>
> Jim
>
> On Wed, Sep 30, 2020 at 12:26 PM array chip  wrote:
> >
> > Hi Jim,
> >
> > I tried the clip() function below, surprisingly it did not work! I read the 
> > R help file and feel your script should work. To have a workable example, I 
> > used the ovarian dataset in the survival package as an example:
> >
> > ovarian1<-ovarian
> > ovarian1$fustat[ovarian$futime>450]<-0
> > ovarian1$futime[ovarian$futime>450]<-450
> >
> > ovarian2<-subset(ovarian,futime>450)
> >
> > fit1 <- survfit(Surv(futime, fustat) ~ rx, data = ovarian1)
> > fit2 <- survfit(Surv(futime, fustat) ~ rx, data = ovarian2)
> >
> > plot(fit1, xlim=c(0,1200), col = 1:2)
> > abline(v=450)
> > xylim<-par("usr")
> > clip(450,xylim[2],xylim[3],xylim[4])
> > lines(fit2, col = 3:4,lty=2)
> >
> > I can still see that the extra horizontal line on the top.
> >
> > Can you or anyone have any suggestion what went wrong?
> >
> > Thanks,
> >
> > John
> >
> >
> > On Tuesday, September 29, 2020, 01:35:48 AM PDT, Jim Lemon 
> >  wrote:
> >
> >
> >
> >
> >
> > Hi John,
> > Perhaps the most direct way would be:
> >
> > plot(fit1, col=1:2)
> > xylim<-par("usr")
> > clip(4,xylim[2],xylim[3],xylim[4])
> > lines(fit2,col=1:2)
> >
> > Remember that the new clipping rectangle will persist until you or
> > something else resets it.
> >
> > Jim
> >
> > On Tue, Sep 29, 2020 at 10:34 AM array chip via R-help
> >  wrote:
> > >
> > > Hello,
> > >
> > > Can anyone suggest a simple way to generate a Kaplan-Meier plot with 2 
> > > survfit objects, just like this one:
> > >
> > > https://drive.google.com/file/d/1fEcpdIdE2xYtA6LBQN9ck3JkL6-goabX/view?usp=sharing
> > >
> > > Suppose I have 2 survfit objects: fit1 is for the curve on the left 
> > > (survtime has been truncated to the cutoff line: year 5), fit2 is for the 
> > > curve on the right (minimum survival time is at the cutoff line: year 5), 
> > > but if I do the following:
> > >
> > > plot(fit1, col=1:2)
> > > lines(fit2,col=1:2)
> > >
> > > Then I will have an horizontal line on the top that connect from 0 to 4 
> > > years, which I do not want that to be drawn (see blue arrow below):
> > >
> > > https://drive.google.com/file/d/178mQGlhnaOg9PA-oE-W_W5CtrGD03ljH/view?usp=sharing
> > >
> > > Can anyone have a strategy to make this kind of plot happen?
> > >
> > > Thanks,
> > >
> > > John
> >
> > >
> > > __
> > > 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] 2 KM curves on the same plot

2020-09-30 Thread array chip via R-help
Hi Jim,

I found out why clip() does not work with lines(survfit.object)!

If you look at code of function survival:::lines.survfit, in th middle of the 
code:

    do.clip <- getOption("plot.survfit")
    if (!is.null(xx <- do.clip$plotclip)) 
        clip(xx[1], xx[2], xx[3], xx[4])

This will reset the clipping to the defualt plot region!

So I just comment out the last 2 lines of the above 3 lines, and created a 
customized lines2 function. Now it works!

It's fun to learn clip().

Thanks,

John


On Wednesday, September 30, 2020, 01:47:55 AM PDT, Jim Lemon 
 wrote: 


Hi John,
Hmmm, this works:

plot(1:10)
xylim<-par("usr")
clip(5,xylim[2],xylim[3],xylim[4])
lines(10:1)

so I suspect that there is a "lines" method that resets the clipping
region out of sight. Fortunately Mark Schwartz provided a way to get
your plot so I will give the wall against which I have been banging my
head a break.

Jim

On Wed, Sep 30, 2020 at 1:57 PM array chip  wrote:
>
> Jim,
>
> I tried a few things, I found that clip() works if I just do some regular 
> graphing tasks. But as long as I run lines(fit) with "fit" object is a 
> survfit object, this would reset to default plot region. See the ovarian 
> example below:
>
> library(survival)
> ovarian1<-ovarian
> ovarian1$fustat[ovarian$futime>450]<-0
> ovarian1$futime[ovarian$futime>450]<-450
> ovarian2<-subset(ovarian,futime>450)
>
> fit1 <- survfit(Surv(futime, fustat) ~ rx, data = ovarian1)
> fit2 <- survfit(Surv(futime, fustat) ~ rx, data = ovarian2)
>
> plot(fit1, xlim=c(0,1200), col = 1:2)
> abline(v=450)
> xylim<-par("usr")
> points(-1,-1)
> clip(450,xylim[2],xylim[3],xylim[4])
> abline(h=0.5,col=2)      ### YES, clipping() works!
>
> lines(fit2, col = 3:4,lty=2)  ### clipping does not work! reset to default 
> plot region
> abline(h=0.4,col=2)      ### NO, clipping() does not work!
>
> So disappointed with this, otherwise this would be such a simple method to do 
> what I want.
>
> Thanks,
>
> John
>
> On Tuesday, September 29, 2020, 07:58:53 PM PDT, Jim Lemon 
>  wrote:
>
> Hi John,
> I should have remembered this. For some reason, the clip() function
> doesn't operate until you have issued a graphics command. Try:
>
> points(-1,-1)
>
> before calling lines()
>
> Jim
>
> On Wed, Sep 30, 2020 at 12:26 PM array chip  wrote:
> >
> > Hi Jim,
> >
> > I tried the clip() function below, surprisingly it did not work! I read the 
> > R help file and feel your script should work. To have a workable example, I 
> > used the ovarian dataset in the survival package as an example:
> >
> > ovarian1<-ovarian
> > ovarian1$fustat[ovarian$futime>450]<-0
> > ovarian1$futime[ovarian$futime>450]<-450
> >
> > ovarian2<-subset(ovarian,futime>450)
> >
> > fit1 <- survfit(Surv(futime, fustat) ~ rx, data = ovarian1)
> > fit2 <- survfit(Surv(futime, fustat) ~ rx, data = ovarian2)
> >
> > plot(fit1, xlim=c(0,1200), col = 1:2)
> > abline(v=450)
> > xylim<-par("usr")
> > clip(450,xylim[2],xylim[3],xylim[4])
> > lines(fit2, col = 3:4,lty=2)
> >
> > I can still see that the extra horizontal line on the top.
> >
> > Can you or anyone have any suggestion what went wrong?
> >
> > Thanks,
> >
> > John
> >
> >
> > On Tuesday, September 29, 2020, 01:35:48 AM PDT, Jim Lemon 
> >  wrote:
> >
> >
> >
> >
> >
> > Hi John,
> > Perhaps the most direct way would be:
> >
> > plot(fit1, col=1:2)
> > xylim<-par("usr")
> > clip(4,xylim[2],xylim[3],xylim[4])
> > lines(fit2,col=1:2)
> >
> > Remember that the new clipping rectangle will persist until you or
> > something else resets it.
> >
> > Jim
> >
> > On Tue, Sep 29, 2020 at 10:34 AM array chip via R-help
> >  wrote:
> > >
> > > Hello,
> > >
> > > Can anyone suggest a simple way to generate a Kaplan-Meier plot with 2 
> > > survfit objects, just like this one:
> > >
> > > https://drive.google.com/file/d/1fEcpdIdE2xYtA6LBQN9ck3JkL6-goabX/view?usp=sharing
> > >
> > > Suppose I have 2 survfit objects: fit1 is for the curve on the left 
> > > (survtime has been truncated to the cutoff line: year 5), fit2 is for the 
> > > curve on the right (minimum survival time is at the cutoff line: year 5), 
> > > but if I do the following:
> > >
> > > plot(fit1, col=1:2)
> > > lines(fit2,col=1:2)
> > >
> > > Then I will have an horizontal line on the top that connect from 0 to 4 
> > > years, which I do not want that to be drawn (see blue arrow below):
> > >
> > > https://drive.google.com/file/d/178mQGlhnaOg9PA-oE-W_W5CtrGD03ljH/view?usp=sharing
> > >
> > > Can anyone have a strategy to make this kind of plot happen?
> > >
> > > Thanks,
> > >
> > > John
> >
> > >
> > > __
> > > 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 lis

Re: [R] How to decrease size of points?

2020-09-30 Thread Medic
The code works as I want, but the points (circles) on the plot are too
big. How to decrease them? Where to insert (for instance) size = 0.8
for points (circles) on plot?
p1 <- p + geom_point(aes(size = Stage), alpha = 1/3) + xlab ("X") +
ylab("Y") + geom_smooth()
Stage is factor, x and y - continuous



Thanks Rui, but I got:
Error: Insufficient values in manual scale. 12 needed but only 1 provided.
(or Error: Continuous value supplied to discrete scale)

__
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] How to decrease size of points?

2020-09-30 Thread Rui Barradas

Hello,

That's the problem of not having a reproducible example, you only gave 
us one value for size.

Try

nsize <- length(unique(df1$Stage))

before the plot and then

p1 + scale_size_manual(values = rep(0.8, nsize))


Hope this helps,

Rui Barradas


Às 17:58 de 30/09/20, Medic escreveu:

The code works as I want, but the points (circles) on the plot are too
big. How to decrease them? Where to insert (for instance) size = 0.8
for points (circles) on plot?
p1 <- p + geom_point(aes(size = Stage), alpha = 1/3) + xlab ("X") +
ylab("Y") + geom_smooth()
Stage is factor, x and y - continuous



Thanks Rui, but I got:
Error: Insufficient values in manual scale. 12 needed but only 1 provided.
(or Error: Continuous value supplied to discrete scale)



__
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] How to decrease size of points?

2020-09-30 Thread Medic
№1 Medic:
The code works as I want, but the points (circles) on the plot are too
big. How to decrease them? Where to insert (for instance) size = 0.8
for points (circles) on plot?

p1 <- p + geom_point(aes(size = Stage), alpha = 1/3) + xlab ("X") +
ylab("Y") + geom_smooth()

Stage is factor, x and y - continuous
===
№2 Rui Barradas:
add the scale_size
p1 + scale_size_manual(values = 0.8)
===
№3 Medic:
Thanks Rui, but I got:
Error: Insufficient values in manual scale. 12 needed but only 1 provided.
(or Error: Continuous value supplied to discrete scale)
===
№4 Rui Barradas:
Try
nsize <- length(unique(df1$Stage))
before the plot and then
p1 + scale_size_manual(values = rep(0.8, nsize))
===
№5 Medic:
Rui, your example is very good!
Now your code works, but not as I want.

Why did I use:
geom_point(aes(size = Stage)...?
In order to receive points of DIFFERENT size!

And what does your code do?
It assigns the same fixed size to ALL points.

I don't need this.
I sincerely thank you and closing the topic!

__
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] How to decrease size of points?

2020-09-30 Thread Rui Barradas

Hello,

Inline.

Às 20:01 de 30/09/20, Medic escreveu:

№1 Medic:
The code works as I want, but the points (circles) on the plot are too
big. How to decrease them? Where to insert (for instance) size = 0.8
for points (circles) on plot?

p1 <- p + geom_point(aes(size = Stage), alpha = 1/3) + xlab ("X") +
ylab("Y") + geom_smooth()

Stage is factor, x and y - continuous
===
№2 Rui Barradas:
add the scale_size
p1 + scale_size_manual(values = 0.8)
===
№3 Medic:
Thanks Rui, but I got:
Error: Insufficient values in manual scale. 12 needed but only 1 provided.
(or Error: Continuous value supplied to discrete scale)
===
№4 Rui Barradas:
Try
nsize <- length(unique(df1$Stage))
before the plot and then
p1 + scale_size_manual(values = rep(0.8, nsize))
===
№5 Medic:
Rui, your example is very good!
Now your code works, but not as I want.

Why did I use:
geom_point(aes(size = Stage)...?
In order to receive points of DIFFERENT size!

And what does your code do?
It assigns the same fixed size to ALL points.


If you want different sizes, the main idea is the same, assign the sizes 
in scale_size_manual.


Stage is a factor so it has a certain number of levels. Create a numeric 
variable, Sizes, from the minimum to the maximum size, set names to its 
values and use that vector.

With 0.4 and 0.8 as min and max size, something like


Sizes <- seq(0.4, 0.8, length.out = length(levels(df1$Stage)))
Sizes <- setNames(Sizes, levels(df1$Stage))

p1 + scale_size_manual(values = Sizes)


Hope this helps,

Rui Barradas



I don't need this.
I sincerely thank you and closing the topic!



__
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] How to decrease size of points?

2020-09-30 Thread Medic
Yes, I just wanted to decrease the STARTING point size!
Sorry for not being able to formulate
Thank you very much, Rui and Avi!
That's all for now. I need to comprehend information.
Medic

__
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] 2 KM curves on the same plot

2020-09-30 Thread Jim Lemon
Hi John,
Brilliant solution and the best sort - when you finally solve your
problem by yourself.

Jim

On Thu, Oct 1, 2020 at 2:52 AM array chip  wrote:
>
> Hi Jim,
>
> I found out why clip() does not work with lines(survfit.object)!
>
> If you look at code of function survival:::lines.survfit, in th middle of the 
> code:
>
> do.clip <- getOption("plot.survfit")
> if (!is.null(xx <- do.clip$plotclip))
> clip(xx[1], xx[2], xx[3], xx[4])
>
> This will reset the clipping to the defualt plot region!
>
> So I just comment out the last 2 lines of the above 3 lines, and created a 
> customized lines2 function. Now it works!
>
> It's fun to learn clip().
>
> Thanks,
>
> John
>
>
> On Wednesday, September 30, 2020, 01:47:55 AM PDT, Jim Lemon 
>  wrote:
>
>
> Hi John,
> Hmmm, this works:
>
> plot(1:10)
> xylim<-par("usr")
> clip(5,xylim[2],xylim[3],xylim[4])
> lines(10:1)
>
> so I suspect that there is a "lines" method that resets the clipping
> region out of sight. Fortunately Mark Schwartz provided a way to get
> your plot so I will give the wall against which I have been banging my
> head a break.
>
> Jim
>
> On Wed, Sep 30, 2020 at 1:57 PM array chip  wrote:
> >
> > Jim,
> >
> > I tried a few things, I found that clip() works if I just do some regular 
> > graphing tasks. But as long as I run lines(fit) with "fit" object is a 
> > survfit object, this would reset to default plot region. See the ovarian 
> > example below:
> >
> > library(survival)
> > ovarian1<-ovarian
> > ovarian1$fustat[ovarian$futime>450]<-0
> > ovarian1$futime[ovarian$futime>450]<-450
> > ovarian2<-subset(ovarian,futime>450)
> >
> > fit1 <- survfit(Surv(futime, fustat) ~ rx, data = ovarian1)
> > fit2 <- survfit(Surv(futime, fustat) ~ rx, data = ovarian2)
> >
> > plot(fit1, xlim=c(0,1200), col = 1:2)
> > abline(v=450)
> > xylim<-par("usr")
> > points(-1,-1)
> > clip(450,xylim[2],xylim[3],xylim[4])
> > abline(h=0.5,col=2)  ### YES, clipping() works!
> >
> > lines(fit2, col = 3:4,lty=2)  ### clipping does not work! reset to default 
> > plot region
> > abline(h=0.4,col=2)  ### NO, clipping() does not work!
> >
> > So disappointed with this, otherwise this would be such a simple method to 
> > do what I want.
> >
> > Thanks,
> >
> > John
> >
> > On Tuesday, September 29, 2020, 07:58:53 PM PDT, Jim Lemon 
> >  wrote:
> >
> > Hi John,
> > I should have remembered this. For some reason, the clip() function
> > doesn't operate until you have issued a graphics command. Try:
> >
> > points(-1,-1)
> >
> > before calling lines()
> >
> > Jim
> >
> > On Wed, Sep 30, 2020 at 12:26 PM array chip  wrote:
> > >
> > > Hi Jim,
> > >
> > > I tried the clip() function below, surprisingly it did not work! I read 
> > > the R help file and feel your script should work. To have a workable 
> > > example, I used the ovarian dataset in the survival package as an example:
> > >
> > > ovarian1<-ovarian
> > > ovarian1$fustat[ovarian$futime>450]<-0
> > > ovarian1$futime[ovarian$futime>450]<-450
> > >
> > > ovarian2<-subset(ovarian,futime>450)
> > >
> > > fit1 <- survfit(Surv(futime, fustat) ~ rx, data = ovarian1)
> > > fit2 <- survfit(Surv(futime, fustat) ~ rx, data = ovarian2)
> > >
> > > plot(fit1, xlim=c(0,1200), col = 1:2)
> > > abline(v=450)
> > > xylim<-par("usr")
> > > clip(450,xylim[2],xylim[3],xylim[4])
> > > lines(fit2, col = 3:4,lty=2)
> > >
> > > I can still see that the extra horizontal line on the top.
> > >
> > > Can you or anyone have any suggestion what went wrong?
> > >
> > > Thanks,
> > >
> > > John
> > >
> > >
> > > On Tuesday, September 29, 2020, 01:35:48 AM PDT, Jim Lemon 
> > >  wrote:
> > >
> > >
> > >
> > >
> > >
> > > Hi John,
> > > Perhaps the most direct way would be:
> > >
> > > plot(fit1, col=1:2)
> > > xylim<-par("usr")
> > > clip(4,xylim[2],xylim[3],xylim[4])
> > > lines(fit2,col=1:2)
> > >
> > > Remember that the new clipping rectangle will persist until you or
> > > something else resets it.
> > >
> > > Jim
> > >
> > > On Tue, Sep 29, 2020 at 10:34 AM array chip via R-help
> > >  wrote:
> > > >
> > > > Hello,
> > > >
> > > > Can anyone suggest a simple way to generate a Kaplan-Meier plot with 2 
> > > > survfit objects, just like this one:
> > > >
> > > > https://drive.google.com/file/d/1fEcpdIdE2xYtA6LBQN9ck3JkL6-goabX/view?usp=sharing
> > > >
> > > > Suppose I have 2 survfit objects: fit1 is for the curve on the left 
> > > > (survtime has been truncated to the cutoff line: year 5), fit2 is for 
> > > > the curve on the right (minimum survival time is at the cutoff line: 
> > > > year 5), but if I do the following:
> > > >
> > > > plot(fit1, col=1:2)
> > > > lines(fit2,col=1:2)
> > > >
> > > > Then I will have an horizontal line on the top that connect from 0 to 4 
> > > > years, which I do not want that to be drawn (see blue arrow below):
> > > >
> > > > https://drive.google.com/file/d/178mQGlhnaOg9PA-oE-W_W5CtrGD03ljH/view?usp=sharing
> > > >
> > > > Can anyone have a strategy to make this kind of plot happen?

Re: [R] Help with the Error Message in R "Error in 1:nchid : result would be too long a vector"

2020-09-30 Thread Rahul Chakraborty
Hello Rui,

Thanks a lot for your response. But, I will surely say that the data I
attached is in long format as it has 18 rows (3 alternatives*3
questions* 2 individuals). Had it been a wide format data it would
have had 6 rows (3 questions* 2 individuals). But, anyway thanks.

Best,
Rahul


On Wed, Sep 23, 2020 at 3:23 AM Rui Barradas  wrote:
>
> Hello,
>
> Please keep this on the list so that others can give their contribution.
>
> If you have reshaped your data can you post the code you ran to reshape
> it? Right now we only have the original attachment, in wide format, not
> the long format data.
>
> Rui Barradas
>
> Às 21:55 de 22/09/20, Rahul Chakraborty escreveu:
> > Hi,
> >
> > Thank you so much for your reply.
> > Yes, thank you for pointing that out, I apologise for that error in
> > the variable name. However, my data is in long format.
> >
> > See, my first column is IND which identifies my individuals,
> > second column is QES which identifies the question number each
> > individual faces, 3rd column is a stratification code that can be
> > ignored. Columns 6-13 are alternative specific variables and rest are
> > individual specific. So 1st 3 rows indicate 1st question faced by 1st
> > individual containing 3 alternatives, and so on. So, I have already
> > arranged the data in long format.
> >
> > With that in mind if I use shape="long" it still gives me error.
> >
> > Best  regards,
> >
> > On Tue, Sep 22, 2020 at 11:00 PM Rui Barradas  wrote:
> >>
> >> Hello,
> >>
> >> I apologize if the rest of quotes prior to David's email are missing,
> >> for some reason today my mail client is not including them.
> >>
> >> As for the question, there are two other problems:
> >>
> >> 1) Alt_name is misspelled, it should be ALT_name;
> >>
> >> 2) the data is in wide, not long, format.
> >>
> >> A 3rd, problem is that in ?dfidx it says
> >>
> >> alt.var
> >> the name of the variable that contains the alternative index (for a long
> >> data.frame only) or the name under which the alternative index will be
> >> stored (the default name is alt)
> >>
> >>
> >> So if shape = "wide", alt.var is not needed.
> >> But I am not a user of package mlogit, I'm just guessing.
> >>
> >> The following seems to fix it (it doesn't throw errors).
> >>
> >>
> >> mldata1 <- dfidx(mydata, shape = "wide",
> >>#alt.var = "ALT_name",
> >>choice = "Choice_binary",
> >>id.var = "IND")
> >>
> >>
> >> Hope this helps,
> >>
> >> Rui Barradas
> >>
> >>
> >> Às 16:15 de 22/09/20, David Winsemius escreveu:
> >>> You were told two things about your code:
> >>>
> >>>
> >>> 1) mlogit.data is deprecated by the package authors, so use dfidx.
> >>>
> >>> 2) dfidx does not allow duplicate ids in the first two columns.
> >>>
> >>>
> >>> Which one of those are you asserting is not accurate?
> >>>
> >>>
> >
> >
> >



-- 
Rahul Chakraborty
Research Fellow
National Institute of Public Finance and Policy
New Delhi- 110067

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