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


[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] Date format

2020-05-10 Thread Medic
Many Thanks!!!
> cpolw...@chemo.org.uk:
> Your X axis is plotting mydata not date?
> Use aes(x=date

__
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] Date format

2020-05-10 Thread Medic
I took a SAMPLE CODE (for Connected scatterplot) from the R gallery
and applied to MY DATA, but got:
"Don't know how to automatically pick scale for object ..."
P.S. 1) R ver. 4.0 (Yes, Jeff);  2) Attached: mydata_dput (1 КБ)

SAMPLE CODE
library(ggplot2)
library(dplyr)
library(hrbrthemes)
data <- 
read.table("https://raw.githubusercontent.com/holtzy/data_to_viz/master/Example_dataset/3_TwoNumOrdered.csv
", header=T)

data$date <- as.Date(data$date)

# Plot
data %>%
  tail(10) %>%
  ggplot( aes(x=date, y=value)) +
geom_line( color="grey") +
geom_point(shape=21, color="black", fill="#69b3a2", size=6) +
theme_ipsum() +
ggtitle("Evolution of bitcoin price")

==
MY DATA
mydata <- read.table("E:/mydata.csv", header=TRUE, sep=";", dec=",")

str(mydata)
'data.frame': 7 obs. of  2 variables:
 $ date : chr  "01.01.2000" "02.01.2000" ...
 $ value: int  11 12 ...

mydata$date <- as.Date(mydata$date, "%d.%m.%Y")

str(mydata$date)
Date[1:7], format: "2000-01-01"

# Bert, thanks for the explanation!
# Rainer, thanks for the specific code!

# And then the problem:
mydata %>%
tail(10) %>%
ggplot( aes(x=mydata, y=value)) +
geom_line( color="grey") +
geom_point(shape=21, color="black", fill="#69b3a2", size=6) +
theme_ipsum() +
ggtitle("Evolution")

"Don't know how to automatically pick scale for object of type
data.frame. Defaulting to continuous.
Error: Aesthetics must be either length 1 or the same as the data (7): x"
__
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] Date format

2020-05-09 Thread Medic
I took a SAMPLE CODE (for Connected scatterplot) from the R gallery
and applied to MY DATA, but got:
"Error in as.Date.numeric(mydata$date) : 'origin' must be supplied".
P.S. I can not understand ?as.Date()

SAMPLE CODE
library(ggplot2)
library(dplyr)
library(hrbrthemes)
data <- 
read.table("https://raw.githubusercontent.com/holtzy/data_to_viz/master/Example_dataset/3_TwoNumOrdered.csv;,
header=T)

str(data)
'data.frame': 1822 obs. of  2 variables:
 $ date : chr  "2013-04-28" "2013-04-29" "2013-04-30" "2013-05-01" ...
 $ value: num  136 147 147 140 126 ...

data$date <- as.Date(data$date)

# Plot
data %>%
  tail(10) %>%
  ggplot( aes(x=date, y=value)) +
geom_line( color="grey") +
geom_point(shape=21, color="black", fill="#69b3a2", size=6) +
theme_ipsum() +
ggtitle("Evolution of bitcoin price")


MY DATA
mydata <- read.table("E:/mydata.csv", header=TRUE, sep=";", dec=",")

str(mydata)
'data.frame': 7 obs. of  2 variables:
 $ date : chr  "01.01.2000" "02.01.2000" "03.01.2000" "04.01.2000" ...
 $ value: int  11 12 13 14 15 16 17

mydata$date <- as.Date(mydata$date)
Error in as.Date.numeric(mydata$date) : 'origin' must be supplied

__
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] Survival analysis

2020-04-26 Thread Medic
cpolwart wrote:
> the event can only happen once
>
1. Yes, I'm not interested in repeat events.
2. I just had an interest in learning the code for survival analysis
in case there are: event, left censored (not left truncating) and
right censored, nothing more! But I no longer want to burden anyone
with my question. (It is not so important.) Thank you sincerely!

__
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] Survival analysis

2020-04-26 Thread Medic
Very grateful for the all comments!

My data contains:
• left censored
• right censored
• events
(interval censored does not contain!)

(P.S. I understood, that the code with "type = 'left'" is not
suitable, because is ONLY for left-censored.)

I wanted to get the appropriate code for my so mix data mainly in
order to get a graphical display (graphic aspect) of such model.

__
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] Survival analysis

2020-04-17 Thread Medic
On 2020-04-17 20:06, Medic wrote:
> I can't understand how to do a survival analysis (?Surv ()) when some
> event occurred before the start of observation (left censored). If I
> understand correctly, there are two methods. I chose a method with: 1)
> time from the start of treatment to the event and 2) the indicator of
> the event. I did (in my data) the event indicator so:
> 1 - event, 2 - event before the start of observation, 0 - no event

I have no experience of left censoring beyond the text book.  Is your
left censored data the SAME event or a different event?

YES, THE SAME!

> ---
> library(survival)
> left_censor_data <- read.table("left.csv", header = TRUE, sep = ";")
> #sep = ";" it's right!
> dput(left_censor_data, file="left_censor_data") #file attached
> left_censor_data
>'data.frame':   11 obs. of  2 variables:
>$ timee : int  5 151 33 37 75 14 7 9 1 45 ...
>$ eventt: int  2 0 0 0 0 0 0 2 0 1 ...
># 1—event, 2 – event before the start of observation , 0 – no event

So if I read this data correctly the first observation is left censored.
What does the time "5" refer to?  Is that 5 days BEFORE observation the
event happened?

YES, EXACTLY!

My text book understanding of left censored data was that your
censored points would
have time 0.

I TRIED TO SET TIME 0 NOW (for censored points), AND RECEIVED THE SAME
WARNING (AND THE CURVE TURNED OUT WRONG)

> sur <- Surv(time = left_censor_data$timee,  event =
> left_censor_data$eventt, type = "left")
>   WARNING message:
>   In Surv(time = left_censor_data$timee, event =
> left_censor_data$eventt,  :
>   Invalid status value, converted to NA
>
> #Why such a WARNING message?
> #Then everything turns out wrong

Is the censoring type you want LEFT TRUNCATION rather than LEFT.
If they are also right censored I think R Surv calls these Counting.

I SAY ABOUT LEFT CENSORING (NOT ABOUT LEFT TRUNCATION)!
(COUNTING? I DO NOT UNDERSTAND THIS.)

THANKS! I HOPE SOMEONE EXPLAIN TO ME
1) HOW TO COMPILE THE DATA and
2) WRITE A 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] Survival analysis

2020-04-17 Thread Medic
I can't understand how to do a survival analysis (?Surv ()) when some
event occurred before the start of observation (left censored). If I
understand correctly, there are two methods. I chose a method with: 1)
time from the start of treatment to the event and 2) the indicator of
the event. I did (in my data) the event indicator so:
1 - event, 2 - event before the start of observation, 0 - no event
---
library(survival)
left_censor_data <- read.table("left.csv", header = TRUE, sep = ";")
#sep = ";" it's right!
dput(left_censor_data, file="left_censor_data") #file attached
left_censor_data
   'data.frame':   11 obs. of  2 variables:
   $ timee : int  5 151 33 37 75 14 7 9 1 45 ...
   $ eventt: int  2 0 0 0 0 0 0 2 0 1 ...
   # 1—event, 2 – event before the start of observation , 0 – no event

sur <- Surv(time = left_censor_data$timee,  event =
left_censor_data$eventt, type = "left")
  Warning message:
  In Surv(time = left_censor_data$timee, event = left_censor_data$eventt,  :
  Invalid status value, converted to NA

#Why such a message?
#Then everything turns out wrong
__
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] Split

2019-12-23 Thread Medic
Dear Burt, you gave a very elegant solution. Many thanks!
Jeff, I understand your solution, thank you very much for your time!
Colleague Milos, patronage is exactly what I need. I hope for your
further guidance! (Rcmdr is not enough for some purposes.)
Dear Ivan, I used your solution! It's the most understandable for me! Thanks!!!

__
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] Split

2019-12-23 Thread Medic
I have
mydata$var
#this is ONE group of patients

And I would like to get
median and ICR of mydata$var.

How can I get this?
With summary (mydata$var)!

Ok!

And now I would like to get THE SAME, but for TWO group: male and
female (which are contained in the group mydata$var)

How can I get this?
First I need to split mydata$var by mydata$sex, and then take:

summary (for male)
and
summary (for female)

That's all I want

Bert,
ave(mydata$var, madata$sex, FUN=median)
gives me:
[1] 5.6 5.6 5.6 5.6 5.6 5.6 5.6 5.6 5.6 5.6 5.6 5.6 5.6 5.6 5.6 5.6
5.6 5.6 5.6 5.6
[21] 6.0 6.0 6.0 6.0 6.0 6.0 6.0 6.0 6.0 6.0 6.0 6.0 6.0 6.0 6.0 6.0
6.0 6.0 6.0 6.0
What is it?
It is an endless(???) repetition of the median.
Moreover, there is no ICR.

Jeff,
your constructions are too complicated for me
===
P.S. Such simple thing and so difficult?! (I begin think about the Excel.)

__
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] Split

2019-12-23 Thread Medic
I have
mydata$var

and I have
mydata$group #two group

I would like to split
mydata$var
by
mydata$group #to get var1 and var2

And then get
summary (var1, var2)  #this is my finite aim

How to encode it all?

__
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] choose randomly

2019-12-18 Thread Medic
Bert, I am very grateful for your clear explanation!!!
  Bert Gunter
  If n = N, then this is unnecessarily complicated.
  sample(mydata$Temperature)
  is all you need (see ?sample).
  If n < N, then the "trick" is not done.
  sample(mydata$Temperature, n)
  is what is wanted.
  Bert

Thank you, Jim, you always come to the rescue!
  Jim Lemon
  mydata$Temperature[sample(1:N,N)
  should do the trick. You will just get a pseudo-randomly shuffled set
  of the same values.
  Jim

Medic  wrote:
> > Variable temperature:
> > mydata$temperature
> > has N values.
> > With what code to сhoice (without return) n values from them RANDOMLY?

__
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] choose randomly

2019-12-18 Thread Medic
Variable temperature:
mydata$temperature
has N values.
With what code to сhoice (without return) n values from them RANDOMLY?

__
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] Creating map in R

2019-11-22 Thread Medic
Thank you very much!
> From: Michael Hannon 
> ... following might be useful in this case:
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

__
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] Creating map in R

2019-11-21 Thread Medic
Creating map in R. I have all the files (with different extensions)
for the country I need. The problem is that I don’t know how to use
them in R. I began according to information on the Internet, and
immediately ran into difficulties (see below):

`library("tmaptools")
geo <- read_shape("Rom.shp", as.sf = TRUE)
This function is deprecated and has been migrated to
github.com/mtennekes/oldtmaptools`

I turned to a similar function, but get an UNCLEAR message

`library(raster)
geo <- shapefile ("Rus.shp")
Error in .local(x, ...) : file.exists(extension(x, ".shx")) is not TRUE`

__
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] Read shp file

2019-11-21 Thread Medic
Help me. pls, to read .shp file.

`library("tmaptools")
geo <- read_shape("Rom.shp", as.sf = TRUE)
This function is deprecated and has been migrated to
github.com/mtennekes/oldtmaptools`

I have to turn to another function, but I get an unclear message

`library(raster)
geo <- shapefile ("Rus.shp")
Error in .local(x, ...) : file.exists(extension(x, ".shx")) is not TRUE`

__
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] pairs.panels ()

2019-11-20 Thread Medic
Hi, Sarah,
Thank you not just for the answer, but for the teaching (!) answer!
Yes, cex.labels is what I need!

__
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] pairs.panels ()

2019-11-19 Thread Medic
Point me, please, the parameter for changing the font size for the
variable name in pairs.panels ()
__
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] Change Y-axis labels

2019-09-05 Thread Medic
For David Winsemius.
As always, You help out! Immensely grateful!

__
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] Change Y-axis labels

2019-09-04 Thread Medic
The Y scale is divided (by default) as:
0.0 ... 0.2 ... 0.4 ... 0.6 ... 0.8 ...1.0
But I would like so:
0 ... 20 ... 40 ... 60 ... 80... 100
(with rotating axis labels)
When I use par function (marked as comment here) it turns out
correctly for ONLY ONE picture?! Help me, please. (This is the code
for restricted mean survival time.)

install.packages("survival")
install.packages("survRM2")
library(survival)
library(survRM2)
#automatically creates a sample data
D=rmst2.sample.data()
time=D$time
status=D$status
arm=D$arm
tau=NULL
a=rmst2(time, status, arm, tau=10)
#par(yaxt="n")
plot(a, xlab="Years", ylab="Probability", density=60)
#par(yaxt="s")
#axis(side = 2, at = seq(0, 1, 0.2), labels = seq(0, 100, 20), las = 1)

__
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] plot (cox)

2019-04-15 Thread Medic
Dear Sarah,
everything worked out! Thank You!!!
--
Sarah Goslee :
> Well, you don't provide a reproducible example, so there's only so
> much we can do. The help for par is a lot, but I told you which option
> to use. Did you try reading the examples for ?axis at all?
> plot (cox, col=1:2, xscale=1, xlab="OS",  ylab="Probability", xaxt="n")
> axis(1, at=seq(0, 48, by=12))
> Or whatever axis values you actually want.

> > Sarah Goslee :
> > > You can presumably use xaxt="n" in your plot() statement (see ?par for
> > > details), and then use axis() to make anything you'd like (see ?axis
> > > for details).
> > --
> > >> Medic  wrote:
> > >> In this code:
> > >> plot (cox, col=1:2, xscale=1, xlab="OS",  ylab="Probability")
> > >> the X scale is divided (by default) as:
> > >>  0 ... 50 ... 100 ... 150 ... 200
> > >> And I would like so:
> > >> 0 ... 12 ... 24 ... 36 ... 48.
> > >> I looked ?plot(cox), but did not understand what argument is
> > >> responsible for this.

__
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] plot (cox)

2019-04-15 Thread Medic
Thanks, but too hard for me

Sarah Goslee :
> You can presumably use xaxt="n" in your plot() statement (see ?par for
> details), and then use axis() to make anything you'd like (see ?axis
> for details).
------
>> Medic  wrote:
>> In this code:
>> plot (cox, col=1:2, xscale=1, xlab="OS",  ylab="Probability")
>> the X scale is divided (by default) as:
>>  0 ... 50 ... 100 ... 150 ... 200
>> And I would like so:
>> 0 ... 12 ... 24 ... 36 ... 48.
>> I looked ?plot(cox), but did not understand what argument is
>> responsible for this.

__
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] plot (cox)

2019-04-15 Thread Medic
In this code:

plot (cox, col=1:2, xscale=1, xlab="OS",  ylab="Probability")

the X scale is divided (by default) as:

 0 ... 50 ... 100 ... 150 ... 200

And I would like so:

0 ... 12 ... 24 ... 36 ... 48.

I looked ?plot(cox), but did not understand what argument is
responsible for this.

Pls, help me!

__
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] Thanks! Re: Kaplan-Meier plot

2019-01-17 Thread Medic
Bert Gunter:
"Have you consulted ?plot.survfit ? "

Marc Schwartz
"The 'mark.time' argument for plot.survfit() is FALSE by default."

Great thanks, Bert, for explanation in which documentation to view information!
Thank you very much, Marc!
Yes, specification required:
plot (km, mark.time=TRUE)
for the appearance censored data on the Kaplan-Meier plot!

__
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] Kaplan-Meier plot

2019-01-17 Thread Medic
According to the guidelines (if I'm not mistaken), the code below is
sufficient (without any specification) to give Kaplan-Meier curves with
censored data markings on Kaplan-Meier curves. But in my case censored data
don't appears on the curves?!

library(survival)
mydata<-read.csv (file="C:/mydata/mydata.csv", header=TRUE, sep=";" )
# Sic! The separator in my csv file is ";"

dput (mydata, "dputmydata.r")
#attached

Y <- Surv (mydata$time, mydata$status == 2)
# 2 -- encodes event

km <- survfit (Y~mydata$stage)

plot (km)
__
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] SURVDIFF()

2019-01-12 Thread Medic
Dear David,
you are (as always) come to the rescue!
With your wonderful pedagogical talent of explanation!
Many thanks for the support!
My warmest and sincere wishes for the new year!

__
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] SURVDIFF()

2019-01-12 Thread Medic
How to note (in code) a few (!) adjusting covariates for cox
regression. I had an example for one covariate, and tried (according
to my own understanding) two variantes of code  (pls, see below), and
got ... a different p-value. What is the right code? Many thanks!!!

(1)
survdiff (Surv(survt,status)~clinic+strata(prison, dose, gender),data=addicts)
N Observed Expected (O-E)^2/E (O-E)^2/V
clinic=1 163  122106.2  2.3514
clinic=2  75   28 43.8  5.7014
Chisq= 14  on 1 degrees of freedom, p= 2e-04

(2)
survdiff (Surv(survt,status)~clinic+strata(prison+dose+gender),data=addicts)
N Observed Expected (O-E)^2/E (O-E)^2/V
clinic=1 163  122106.2  2.35  12.1
clinic=2  75   28 43.8  5.69  12.1
Chisq= 12.1  on 1 degrees of freedom, p= 5e-04

__
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] THANKS! Re: Installation...

2018-12-24 Thread Medic
1. Dear John, thank you for the important point!

2. Dear Duncan, thank you for the clear clarification!


__
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] Installation Re: Problems with library...

2018-12-24 Thread Medic
1. Jeff, thank you for your explanation!

2 Kum-Hoe, thank you for appointed treatment!

---
QUESTION!
I will also (with R) reinstall the RStudio. Allow me to ask a QUESTION
(about packages installing) -- which variant is right:
1) installing all packages only in R (RStudio will take them automatically)
2) installing all packages only in RStudio (R will take them automatically)
3) installing all packages in R and in RStudio (i.e. in each of them)
Thanks, 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.


[R] Problems with library(survival)

2018-12-23 Thread Medic
> install.packages("survival")
package ‘survival’ successfully unpacked and MD5 sums checked
> library(survival)
Error: package or namespace load failed for ‘survival’ in get(Info[i,
1], envir = env):
 lazy-load database 'C:/Program
Files/R/R-3.5.1/library/lattice/R/lattice.rdb' is corrupt
In addition: Warning message:
In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
---
MY QUESTION IS: what does this mean? what is the problem here?

__
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] HISTOGRAM

2018-11-10 Thread Medic
Rui Barradas,
thank you for your prompt response, your code will be useful to me in
the future!

Rick Bilonick ("your data appear to be categorical"),
thank you very much for your comment (I would have to more correctly
express my task).

JIM Lemon,
THANKS!!! THIS IS EXACTLY what I needed!

__
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] HISTOGRAM

2018-11-09 Thread Medic
What would be the correct code (simplest version) (without gplot())
for histogram (with 7 bars), which would include 7 names of bars under
the X-axis. The data are:

name number
ds6277
lk 24375
ax46049
dd70656
az216544
df 220620
gh641827

(I'm attaching mydata.r, making with dput.)

My attempt is:

options(scipen=999)
with (mydata, hist(number))

P.S. I can't understand how the column "name" to include in a 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] cox model

2018-11-03 Thread Medic
I need a R-code for a situation that is well described in the sas help. I
would be very grateful for the help!
"Time-dependent variables can be used to model the effects of subjects
transferring from one treatment group to another. One example of the need
for such strategies is the Stanford heart transplant program. Patients are
accepted if physicians judge them suitable for heart transplant. Then, when
a donor becomes available, physicians choose transplant recipients
according to various medical criteria. A patient’s status can be changed
during the study from waiting for a transplant to being a transplant
recipient. Transplant status can be defined by the time-dependent covariate
function z=z(t) as:
z(t)= 0 (if the patient has not received the transplant at time t)
and 1 (if has received)

__
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] survival analysis question

2018-10-31 Thread Medic via R-help

When I run the code from the book Kleinbaum "Survival analysis" (7. Running an 
extended cox model. Page 646) I got an ERROR. What do you think is the reason? 
I attach a file with few lines of dataset "addicts-dput.r".
> library(cmprsk)
> addicts = read.csv ("addicts.csv") 
   id clinic status survt prison dose
1  1      1      1   428      0   50
2  2      1      1   275      1   55
3  3      1      1   262      0   55
4  4      1      1   183      0   30
5  5      1      1   259      1   65
6  6      1      1   714      0   55
7  7      1      1   438      1   65
8  8      1      0   796      1   60
9  9      1      1   892      0   50
> addicts.cp=survSplit(addicts, cut=addicts$survt[addicts$status==1], 
> end="survt", event="status",start="start", id="id")
ERROR in survSplit(addicts, cut = addicts$survt[addicts$status == 1],: the 
suggested id name is already present.



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