[R] SAMseq errors
Hi, I am trying to using SAMseq() to analyze my RNA-seq experiment (2 genes x 550 samples) with survival endpoint. It quickly give the following error: > library(samr)Loading required package: imputeLoading required package: > matrixStats Attaching package: ‘matrixStats’ The following objects are masked from ‘package:Biobase’: anyMissing, rowMedians Warning messages:1: package ‘samr’ was built under R version 3.3.3 2: package ‘matrixStats’ was built under R version 3.3.3 > samfit<-SAMseq(data, PFI.time,censoring.status=PFI.status, > resp.type="Survival") Estimating sequencing depths...Error in quantile.default(prop, c(0.25, 0.75)) : missing values and NaN's not allowed if 'na.rm' is FALSEIn addition: Warning message:In sum(x) : integer overflow - use sum(as.numeric(.))Error during wrapup: cannot open the connection > sessionInfo()R version 3.3.2 (2016-10-31)Platform: x86_64-w64-mingw32/x64 > (64-bit)Running under: Windows 7 x64 (build 7601) Service Pack 1 locale:[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252[4] LC_NUMERIC=C LC_TIME=English_United States.1252 attached base packages:[1] stats graphics grDevices datasets utils methods base other attached packages:[1] samr_2.0 matrixStats_0.52.2 impute_1.48.0 BiocInstaller_1.24.0 rcom_3.1-3 rscproxy_2.1-1 loaded via a namespace (and not attached):[1] tools_3.3.2 I checked, my data matrix and y variables have no missing values. Anyone has suggestions what's going on? Thank you! John [[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] SAMseq errors
Sorry forgot to use plain text format, hope this time it works: Hi, I am trying to using SAMseq() to analyze my RNA-seq experiment (2 genes x 550 samples) with survival endpoint. It quickly give the following error: > library(samr) Loading required package: impute Loading required package: matrixStats Attaching package: ‘matrixStats’ The following objects are masked from ‘package:Biobase’: anyMissing, rowMedians Warning messages: 1: package ‘samr’ was built under R version 3.3.3 2: package ‘matrixStats’ was built under R version 3.3.3 > samfit<-SAMseq(data, PFI.time,censoring.status=PFI.status, > resp.type="Survival") Estimating sequencing depths... Error in quantile.default(prop, c(0.25, 0.75)) : missing values and NaN's not allowed if 'na.rm' is FALSE In addition: Warning message: In sum(x) : integer overflow - use sum(as.numeric(.)) Error during wrapup: cannot open the connection > sessionInfo() R version 3.3.2 (2016-10-31) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1 locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices datasets utils methods base other attached packages: [1] samr_2.0 matrixStats_0.52.2 impute_1.48.0 BiocInstaller_1.24.0 rcom_3.1-3 rscproxy_2.1-1 loaded via a namespace (and not attached): [1] tools_3.3.2 I checked, my data matrix and y variables have no missing values. Anyone has suggestions what's going on? Thank you! 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] Fleming-Harrington weighted log rank test
Hi all, The survdiff() from survival package has an argument "rho" that implements Fleming-Harrington weighted long rank test. But according to several sources including "survminer" package (https://cran.r-project.org/web/packages/survminer/vignettes/Specifiying_weights_in_log-rank_comparisons.html), Fleming-Harrington weighted log-rank test should have 2 parameters "p" and "q" to control the weighting for earlier vs later times in the follow-up. For example, setting rho=1 in survdiff() uses the Peto-Peto modification of Gehan-Wilcox weights, which I can confirm by setting p=1 & 1=0 in comp() from survminer package. similarly rho=0 is equivalent to p=0 & q=0 I am interested in putting more weights on survival difference in later follow-up time. According to comp() from survminer package, that would set p=0 & q=1 for Fleming-Harrington weights. My question is how I can do the same by setting certain values for "rho" in the regular survival() function? Thank you, 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.
Re: [R] Fleming-Harrington weighted log rank test
Thank you David! On Wednesday, February 14, 2018, 6:05:46 PM PST, David Winsemius wrote: > On Feb 14, 2018, at 5:26 PM, David Winsemius wrote: > >> >> On Feb 13, 2018, at 4:02 PM, array chip via R-help >> wrote: >> >> Hi all, >> >> The survdiff() from survival package has an argument "rho" that implements >> Fleming-Harrington weighted long rank test. >> >> But according to several sources including "survminer" package >> (https://cran.r-project.org/web/packages/survminer/vignettes/Specifiying_weights_in_log-rank_comparisons.html), >> Fleming-Harrington weighted log-rank test should have 2 parameters "p" and >> "q" to control the weighting for earlier vs later times in the follow-up. >> >> For example, setting rho=1 in survdiff() uses the Peto-Peto modification of >> Gehan-Wilcox weights, which I can confirm by setting p=1 & 1=0 in comp() >> from survminer package. similarly rho=0 is equivalent to p=0 & q=0 >> >> I am interested in putting more weights on survival difference in later >> follow-up time. According to comp() from survminer package, that would set >> p=0 & q=1 for Fleming-Harrington weights. >> >> My question is how I can do the same by setting certain values for "rho" in >> the regular survival() function? > > I think that survdiff uses a different version than what you have found. The > G-rho family weights are: > > w_j = [Sˆ(tj)]^ρ > > So rather than two parameters on S(t) and (1-S(t)) as in the p,q version, you > only have one parameter applied to S(t). This class handout says that the > G-rho,gamma weighting scheme is not available in survdiff. > Forgot to paste the link: http://www.ics.uci.edu/~dgillen/STAT255/Handouts/lecture4.pdf > -- > David Winsemius > Alameda, CA, USA > > 'Any technology distinguishable from magic is insufficiently advanced.' > -Gehm's Corollary to Clarke's Third Law David Winsemius Alameda, CA, USA 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law [[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] weighed Fleming-Harrington log rank test
Thank you Terry. Right now I can use comp() from survMisc package to do the 2-parameter version of F-H weighting. I think both SAS and stata offer the 2-parameter version, so just thought it would be nice if survdiff() can have that option given it's standard package in R. Thanks! John On Friday, February 16, 2018, 7:08:46 AM PST, Therneau, Terry M., Ph.D. wrote: You are correct that the survreg routine only supports 'rho' of the Fleming-Harrington G-rho tests. This is a function of age -- I wrote the original code back when I was working with Tom (Fleming), and he was only using 1 parameter. Later he and David expanded the test to two parameters. This might be only the second request for the feature in the 30+ years since that date. Terry Therneau [[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] Lattice xyplot
Dear all, I am new to lattice, so would appreciate anyone's help on the questions below. I am using xyplot to plot some trend in my dataset. Using the example dataset attached, I am trying to plot variable "y" over variable "time" for each subject "id": dat<-read.table("dat.txt",sep='\t',header=T,row.names=NULL) xyplot(y ~ time, data=dat, groups=id, aspect = "fill", type = c("p", "l"), xlab = "Time", ylab = "Y") It appears that it just worked fine. But if I sort the "dat" first, the plot will look somewhat different! dat<-dat[order(dat$id, dat$time),]xyplot(y ~ time, data=dat, groups=id, aspect = "fill", type = c("p", "l"), xlab = "Time", ylab = "Y") Why is that? Do you need to sort the data first before using xyplot? Why xyplot can not understand the dataset unless it is sorted first? Thanks, Johnid timey 107 0 6.5 107 1 5.1 107 2 4.2 112 0 5.6 107 3 6.9 112 1 4 112 2 1 119 0 7.6 112 3 4.9 119 1 5.7 120 0 7.1 203 0 7.4 120 2 2.1 203 1 6.3 123 0 6.8 203 2 3.8 119 3 6.1 123 1 3.9 123 2 3 120 3 6 203 3 7.6 207 0 5.8 207 1 3.1 123 3 5.7 209 3 3.6 208 0 4.4 130 0 5.5 131 0 6.9 133 0 5.7 134 0 5.1 209 0 4.9 128 2 2.9 128 1 4.5 130 2 5.9 131 1 6.9 133 2 2.6 133 1 5.7 403 2 3.1 403 0 4.5 128 0 4.5 134 2 2.3 207 3 4.8 130 3 4.9 207 2 2.3 130 1 3.8 131 2 3.9 133 3 3.1 134 1 2.8 209 1 4.2 208 3 2.3 208 1 5.3 208 2 0.8 128 3 4.4 131 3 6.2 209 2 5.7 134 3 4.1 403 3 2.5 119 2 2.3 120 1 3.8 403 1 3.2 __ 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] Lattice xyplot
Thanks all for the clarification! From: Jeff Newmiller To: r-help@r-project.org; Bert Gunter ; array chip Cc: "r-help@r-project.org" Sent: Monday, May 1, 2017 10:53 AM Subject: Re: [R] Lattice xyplot It is not a question of whether lattice "understands" the unsorted data... imagine trying to plot 4 points to form a square instead of a trend line... you would NOT want lattice to sort those points for you. That lattice leaves your data alone gives you more flexibility, even while it adds work for certain applications. -- Sent from my phone. Please excuse my brevity. On May 1, 2017 7:34:09 AM PDT, Bert Gunter wrote: >Yes. type = "l" connects the points in the order given in the data, so >if the x's are not already ordered, the plots will be different after >ordering the x's. > >e.g. > >> x <- c(3,1,2,4,6,5) >> y <- 11:16 >> xyplot(y~x. type = "l") > > >As for why ... that's just the way it was designed. You can always >order the data first, if you don't want this default. > >Cheers, >Bert > >Bert Gunter > >"The trouble with having an open mind is that people keep coming along >and sticking things into it." >-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > >On Sun, Apr 30, 2017 at 6:07 PM, array chip via R-help > wrote: >> Dear all, I am new to lattice, so would appreciate anyone's help on >the questions below. I am using xyplot to plot some trend in my >dataset. Using the example dataset attached, I am trying to plot >variable "y" over variable "time" for each subject "id": >> dat<-read.table("dat.txt",sep='\t',header=T,row.names=NULL) >> xyplot(y ~ time, data=dat, groups=id, aspect = "fill", type = c("p", >"l"), xlab = "Time", ylab = "Y") >> >> It appears that it just worked fine. But if I sort the "dat" first, >the plot will look somewhat different! >> dat<-dat[order(dat$id, dat$time),]xyplot(y ~ time, data=dat, >groups=id, aspect = "fill", type = c("p", "l"), xlab = "Time", ylab = >"Y") >> Why is that? Do you need to sort the data first before using xyplot? >Why xyplot can not understand the dataset unless it is sorted first? >> 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. [[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] deviance in GLM vs. summary.glm
Hi, I am running a logistic regression on a simple dataset (attached) using glm: > dat<-read.table("dat.txt",sep='\t',header=T) If I use summary() on a logistic model: > summary(glm(y~x1*x2,dat,family='binomial')) Coefficients: Estimate Std. Error z value Pr(>|z|)(Intercept) 19.57 5377.01 0.004 0.997x1 -18.59 5377.01 -0.003 0.997x2B -19.57 5377.01 -0.004 0.997x1:x2B 38.15 7604.24 0.005 0.996 As you can see, the interaction term is very insignificant (p = 0.996)! But if I use a anova() to compare a full vs reduced model to evaluate the interaction term: > anova(glm(y~x1+x2,dat,family='binomial'), > glm(y~x1*x2,dat,family='binomial'))Analysis of Deviance Table Model 1: y ~ x1 + x2Model 2: y ~ x1 * x2 Resid. Df Resid. Dev Df Deviance1 22 27.067 2 21 21.209 1 5.8579 This follows a chi-square distribution with 1 df, so the corresponding p value is: > 1-pchisq(5.8679,1)[1] 0.01541944 So I get very different p value on the interaction term, can someone share what's going wrong here? Thanks! Yi "y" "x1""x2" "R" 1 "B" "NR"1 "A" "R" 0 "B" "R" 1 "B" "R" 1 "A" "R" 1 "A" "R" 0 "A" "R" 1 "A" "R" 0 "B" "R" 0 "B" "NR"0 "B" "NR"0 "B" "R" 1 "A" "R" 1 "A" "NR"1 "A" "R" 0 "A" "R" 0 "A" "NR"0 "B" "R" 0 "A" "R" 1 "A" "NR"1 "A" "R" 1 "B" "R" 1 "A" "R" 1 "B" "R" 1 "A" __ 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] gsDesign Pocock & OBF boundary
Hi, I am learning to use your gsDesign package! I have a question about Pocock and OBF boundary. As far as Iunderstand, these 2 boundaries require equal spacing between interim analyses(maybe this is not correct?). But I can still use gsDesign to run an analysisbased on unequal spacing: gsDesign(k=2,test.type=2,timing=c(0.75,1),alpha=0.05,sfu='Pocock')Symmetrictwo-sided group sequential design with90 %power and 5 % Type I Error.Spendingcomputations assume trial stops if a bound is crossed. Sample Size AnalysisRatio* Z Nominal p Spend1 0.796 1.82 0.0346 0.03462 1.061 1.82 0.0346 0.0154Total 0.0500 ++alpha spending:Pocockboundary.*Sample size ratio compared to fixed design with no interim Can anyone share some light whether the above analysis is stillvalid? Or for unequal spacing, I have to use Lan-Demet’s error spendingfunction approximations? Thank you, [[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] gsDesign Pocock & OBF boundary
Sorry for messed up text. Here it goes again: I am learning to use the gsDesign package. I have a question about Pocock and OBF boundary. As far as I can understand, these 2 boundaries require equal spacing between interim analyses (maybe this is not correct?). But looks like I can still use gsDesign to run an analysis based on unequal spacing: > gsDesign(k=2,test.type=2,timing=c(0.75,1),alpha=0.05,sfu='Pocock') Symmetric two-sided group sequential design with 90 %power and 5 % Type I Error.Spending computations assume trial stops if a bound is crossed. Sample Size Analysis Ratio* Z Nominal p Spend 1 0.796 1.82 0.0346 0.0346 2 1.061 1.82 0.0346 0.0154 Total 0.0500 ++alpha spending: Pocock boundary.*Sample size ratio compared to fixed design with no interim Can anyone share some light whether the above analysis is still valid? Or for unequal spacing, I have to use Lan-Demet’s error spending function approximations? Thank you, From: Berend Hasselman To: array chip Cc: R-help Mailing List Sent: Friday, September 22, 2017 11:46 PM Subject: Re: [R] gsDesign Pocock & OBF boundary > On 23 Sep 2017, at 01:32, array chip via R-help wrote: > > Hi, > > I am learning to use your gsDesign package! I have a question about Pocock > and OBF boundary. As far as Iunderstand, these 2 boundaries require equal > spacing between interim analyses(maybe this is not correct?). But I can still > use gsDesign to run an analysisbased on unequal spacing: > gsDesign(k=2,test.type=2,timing=c(0.75,1),alpha=0.05,sfu='Pocock')Symmetrictwo-sided > group sequential design with90 %power and 5 % Type I > Error.Spendingcomputations assume trial stops if a bound is crossed. > Sample Size AnalysisRatio* Z Nominal p Spend 1 0.796 > 1.82 0.0346 0.0346 2 1.061 1.82 0.0346 0.0154 Total > 0.0500 ++alpha spending:Pocockboundary.*Sample size ratio > compared to fixed design with no interim Can anyone share some light whether > the above analysis is stillvalid? Or for unequal spacing, I have to use > Lan-Demet’s error spendingfunction approximations? Thank you, > [[alternative HTML version deleted]] > Your example code is a complete mess. Do NOT post in html. This is a plain text mailing list. Read the Posting Guide (https://www.r-project.org/posting-guide.html). Berend Hasselman] > __ > 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] gsDesign Pocock & OBF boundary
Sorry it didn 't work again. I am on yahoo mail, and just found a switch to change from Rick text to Plain text, so here it goes again: I am learning to use the gsDesign package. I have a question about Pocock and OBF boundary. As far as I can understand, these 2 boundaries require equal spacing between interim analyses (maybe this is not correct?). But looks like I can still use gsDesign to run an analysis based on unequal spacing: > library(gsDesign) > gsDesign(k=2,test.type=2,timing=c(0.75,1),alpha=0.05,sfu='Pocock') Symmetric two-sided group sequential design with 90 % power and 5 % Type I Error. Spending computations assume trial stops if a bound is crossed. Sample Size Analysis Ratio* Z Nominal p Spend 1 0.796 1.82 0.0346 0.0346 2 1.061 1.82 0.0346 0.0154 Total 0.0500 ++ alpha spending: Pocock boundary. * Sample size ratio compared to fixed design with no interim Can anyone share some light whether the above analysis is still valid? Or for unequal spacing, I have to use Lan-Demet’s error spending function approximations? Thank you, From: Jeff Newmiller oject.org>; Berend Hasselman Cc: R-help Mailing List Sent: Sunday, September 24, 2017 12:41 AM Subject: Re: [R] gsDesign Pocock & OBF boundary Still failed. The first secret is in your email program settings, to use Plain Text format (at least for emails you send to this mailing list). The second secret tool to use is the reprex package to let you verify that your code example will do on our computers what it is doing on your computer before you send it to us. That will also involve giving us some sample data or referencing some data already available to us in a relevant package. See [1], [2] and [3] for more discussion of how to succeed at communicating on the Internet regarding R. [1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example [2] http://adv-r.had.co.nz/Reproducibility.html [3] https://cran.r-project.org/web/packages/reprex/index.html (read the vignette) -- Sent from my phone. Please excuse my brevity. On September 23, 2017 9:53:05 PM PDT, array chip via R-help wrote: >Sorry for messed up text. Here it goes again: >I am learning to use the gsDesign package. >I have a question about Pocock and OBF boundary. As far as I can >understand, these 2 boundaries require equal spacing between interim >analyses (maybe this is not correct?). But looks like I can still use >gsDesign to run an analysis based on unequal spacing: >> gsDesign(k=2,test.type=2,timing=c(0.75,1),alpha=0.05,sfu='Pocock') >Symmetric two-sided group sequential design with 90 %power and 5 % Type >I Error.Spending computations assume trial stops if a bound is >crossed. Sample Size Analysis Ratio* Z Nominal p >Spend1 0.796 1.820.0346 0.03462 1.061 1.82 >0.0346 0.0154Total 0.0500 ++alpha spending: >Pocock boundary.*Sample size ratio compared to fixed design with no >interim >Can anyone share some light whether the above analysis is still valid? >Or for unequal spacing, I have to use Lan-Demet’s error spending >function approximations? Thank you, > > > > From: Berend Hasselman >Cc: R-help Mailing List > Sent: Friday, September 22, 2017 11:46 PM > Subject: Re: [R] gsDesign Pocock & OBF boundary > > >> On 23 Sep 2017, at 01:32, array chip via R-help > wrote: >> >> Hi, >> >> I am learning to use your gsDesign package! I have a question about >Pocock and OBF boundary. As far as Iunderstand, these 2 boundaries >require equal spacing between interim analyses(maybe this is not >correct?). But I can still use gsDesign to run an analysisbased on >unequal spacing: >gsDesign(k=2,test.type=2,timing=c(0.75,1),alpha=0.05,sfu='Pocock')Symmetrictwo-sided >group sequential design with90 %power and 5 % Type I >Error.Spendingcomputations assume trial stops if a bound is crossed. > Sample Size AnalysisRatio* Z Nominal p Spend >1 0.796 1.820.0346 0.03462 1.061 1.820.0346 0.0154 >Total 0.0500 ++alpha >spending:Pocockboundary.*Sample size ratio compared to fixed design >with no interim Can anyone share some light whether the above analysis >is stillvalid? Or for unequal spacing, I have to use Lan-Demet’s error >spendingfunction approximations? Thank you, >> [[alternative HTML version deleted]] >> > >Your example code is a complete mess. >Do NOT post in html. This is a plain text mailing list. >Read the Posting Guide (https://www.r-project.org/posting-guide.html). > >Berend Hasselman] > >>
[R] 2 KM curves on the same plot
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.
Re: [R] 2 KM curves on the same plot
Thank you very much Jim, this is great!! 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
Thank you Marc as well! I'll try both ways! Yes this is an oncology study with time set at 5 John On Tuesday, September 29, 2020, 07:08:39 AM PDT, Marc Schwartz wrote: Hi John, >From the looks of the first plot, it would appear that perhaps you are engaged >in a landmark analysis in an oncology setting, with the landmark time set at 5 >years. On the off chance that you are not familiar with the pros and cons of >that methodology, Google "landmark analysis", which should yield a number of >references. With respect to the plot itself, here is one approach, in addition to the one that Jim suggested. This will use a 1 x 2 matrix of plot regions, and adjust the various axes accordingly. library(survival) ## Create two models with the same data for this use, the second adding 150 to the event times ## to mimic a landmark time at 150 weeks fit <- survfit(Surv(time, status) ~ x, data = aml) fit2 <- survfit(Surv(time, status) ~ x, data = aml) fit2$time <- fit2$time + 150 ## create the x 1 x 2 plot matrix par(mfrow = c(1, 2)) ## Set the plot region margins so there is no space to the right par(mar = c(4, 4, 4, 0)) ## Fix the plot limits for consistency ## xaxs = "i" removes the default 4% extensions to the plot region limits plot(fit, axes = FALSE, xlim = c(0, 150), ylim = c(0, 1), xaxs = "i") axis(1, at = seq(0, 150, 50), line = -1) axis(2, las = 1) ## Set the plot region margins so there is no space to the left par(mar = c(4, 0, 4, 4)) ## Set the plot limits for the second time interval plot(fit2, axes = FALSE, xlim = c(150, 300), ylim = c(0, 1), xaxs = "i") axis(1, at = seq(150, 300, 50), line = -1) axis(4, las = 1) ## Draw the vertical line at 150 weeks axis(2, at = seq(0, 1, 0.2), labels = FALSE, lty = "dashed") Regards, Marc Schwartz > On Sep 28, 2020, at 8:33 PM, 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
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
Hi Jim, I tried points(-1,-1) before lines() and before clip(), but either way, it still shows everything, :-( It's interesting that the examples with hist() provided by the R help of clip function works nicely. I also tried a simple linear regression plots below, clip() works, too. dat<-data.frame(x=1:10,y=1:10) fit<-lm(y~x,dat) plot(1:10) abline(fit) xylim<-par("usr") clip(6,xylim[2],xylim[3],xylim[4]) abline(fit,col=2) ## yes, it only shows the fit line from 6 to the right lines(c(2,8),c(5,5)) ## yes, it only shows the line from 6 to the right So it's puzzling that only when using lines() with a survfit() object (ovarian example below), somehow clip() doesn't work 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
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
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
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
Re: [R] linear mixed model using lmer
Thanks Jeff for reminding me that the attachment is removed. I put it in my google drive if anyone wants to test the data (https://drive.google.com/file/d/1lgVZVLHeecp9a_sFxEPeg6353O-qXZhM/view?usp=sharing) I'll try the mixed model mailing list as well. John On Friday, March 4, 2022, 04:56:20 PM PST, Jeff Newmiller wrote: a) There is a mailing list for that: https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models b) Read the Posting Guide, as most attachment types are removed to avoid propagating worms/viruses. (None seen upon receipt of this email.) On March 4, 2022 4:41:57 PM PST, array chip via R-help wrote: >Dear all, I have this simple dataset to measure the yeild of a crop collected >in 2 batches (attached). when I ran a simple inear mixed model using lmer to >estimate within-batch and between-batch variability, the between-batch >variability is 0. The run showed that data is singular. Does anyone know why >the data is singular and what's the reason for 0 variability? is it because >the dataset only has 2 batches? >> daty<-read.table("datx.txt",sep='\t',header=T,row.names=NULL) >> library(lme4)> lmer(yield~1+(1|batch),daty) >boundary (singular) fit: see ?isSingular >Linear mixed model fit by REML ['lmerMod'] >Formula: yield ~ 1 + (1 | batch) > Data: daty >REML criterion at convergence: 115.6358 >Random effects: > Groups Name Std.Dev. > batch (Intercept) 0.000 > Residual 2.789 >Number of obs: 24, groups: batch, 2 >Fixed Effects: >(Intercept) > 5.788 > >Thanks! >John -- Sent from my phone. Please excuse my brevity. [[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] R 4.0.2 is released
Hi, I downloaded R4.0.2 and installed it succesffully without any error. However, when I opened up a R session (using x64) and tried to install packages, I got the following error message: > utils:::menuInstallPkgs() Warning: failed to download mirrors file (internet routines cannot be loaded); using local file 'C:/PROGRA~1/R/R-40~1.2/doc/CRAN_mirrors.csv' Warning: unable to access index for repository https://rweb.crmda.ku.edu/cran/src/contrib: internet routines cannot be loaded Error in install.packages(lib = .libPaths()[1L], dependencies = NA, type = type) : argument "pkgs" is missing, with no default In addition: Warning message: In download.file(url, destfile = f, quiet = TRUE) : unable to load shared object 'C:/PROGRA~1/R/R-40~1.2/modules/x64/internet.dll': LoadLibrary failure: Access is denied. > sessionInfo() R version 4.0.2 (2020-06-22) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18363) Matrix products: default locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.0.2 tools_4.0.2 However, if I load up a session using i386 verson, then everything is ok - I can install packages. Can you and anyone suggest what is going on? Thanks, John On Monday, June 22, 2020, 01:24:20 AM PDT, Peter Dalgaard via R-help wrote: The build system rolled up R-4.0.2.tar.gz (codename "Taking Off Again") this morning. The list below details the changes in this release. You can get the source code from http://cran.r-project.org/src/base/R-4/R-4.0.2.tar.gz or wait for it to be mirrored at a CRAN site nearer to you. Binaries for various platforms will appear in due course. For the R Core Team, Peter Dalgaard These are the checksums (md5 and SHA-256) for the freshly created files, in case you wish to check that they are uncorrupted: MD5 (AUTHORS) = b9c44f9f78cab3184ad9898bebc854b4 MD5 (COPYING) = eb723b61539feef013de476e68b5c50a MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343 MD5 (FAQ) = 4afa171cd982aaa60f0ba92e2e7bc5d6 MD5 (INSTALL) = 7893f754308ca31f1ccf62055090ad7b MD5 (NEWS) = 566a6bb3642e28e6bf01cf98db31137c MD5 (NEWS.0) = bfcd7c147251b5474d96848c6f57e5a8 MD5 (NEWS.1) = eb78c4d053ec9c32b815cf0c2ebea801 MD5 (NEWS.2) = 496062c138e2def06cebccddfb814ac6 MD5 (NEWS.3) = 012e7f4a80cc8ec947bf3f0ff6117ec8 MD5 (R-latest.tar.gz) = 1eac7293d5fe313a56ddabfda02b437e MD5 (README) = f468f281c919665e276a1b691decbbe6 MD5 (RESOURCES) = 529223fd3ffef95731d0a87353108435 MD5 (THANKS) = 251d20510bfc3cc93b82c5a99f7efcc6 MD5 (VERSION-INFO.dcf) = 62496d3a0fd8cc2ed644ea518c052371 MD5 (R-4/R-4.0.2.tar.gz) = 1eac7293d5fe313a56ddabfda02b437e 2cde824a7b18958e5f06b391c801c8288be0f84fa8934b7ddefef23c67e60c09 AUTHORS e6d6a009505e345fe949e1310334fcb0747f28dae2856759de102ab66b722cb4 COPYING 6095e9ffa777dd22839f7801aa845b31c9ed07f3d6bf8a26dc5d2dec8ccc0ef3 COPYING.LIB eddf87b12197c7b3b19cbc9b11c1beab95b14e3dcd715bf37d2f6a8b2a72c2a1 FAQ f87461be6cbaecc4dce44ac58e5bd52364b0491ccdadaf846cb9b452e9550f31 INSTALL ec05bba338358410fae6b34fed061605989ab3601aba1b3fcb45a610d5dd2eb9 NEWS 4e21b62f515b749f80997063fceab626d7258c7d650e81a662ba8e0640f12f62 NEWS.0 12b30c724117b1b2b11484673906a6dcd48a361f69fc420b36194f9218692d01 NEWS.1 e80de410c77f05ff2012fa70051b89119845f734a7fa5c55857e61e4ed7d5f6e NEWS.2 7201d139947afa52b5e09d26dc01445edf444506264355b2185122bc1ed3dce0 NEWS.3 d3bceab364da0876625e4097808b42512395fdf41292f4915ab1fd257c1bbe75 R-latest.tar.gz 2fdd3e90f23f32692d4b3a0c0452f2c219a10882033d1774f8cadf25886c3ddc README 408737572ecc6e1135fdb2cf7a9dbb1a6cb27967c757f1771b8c39d1fd2f1ab9 RESOURCES c9c7cb32308b4e560a22c858819ade9de524a602abd4e92d1c328c89f8037d73 THANKS 10cc5f566a4a5ce49147e7dcfbe9180dba09ccb9efb17298b067309eb799e92e VERSION-INFO.dcf d3bceab364da0876625e4097808b42512395fdf41292f4915ab1fd257c1bbe75 R-4/R-4.0.2.tar.gz This is the relevant part of the NEWS file CHANGES IN R 4.0.2: UTILITIES: * R CMD check skips vignette re-building (with a warning) if the VignetteBuilder package(s) are not available. BUG FIXES: * Paths with non-ASCII characters caused problems for package loading on Windows PR#17833. * Using tcltk widgets no longer crashes R on Windows. * source(*, echo=TRUE) no longer fails in some cases with empty lines; reported by Bill Dunlap in PR#17769. * on.exit() now correctly matches named arguments, thanks to PR#17815 (including patch) by Brodie Gaslam. * regexpr(*, perl=TRUE) no longer returns incorrect positions into text containing characters outside of the Unicode Basic Multilingual Plane on Windows. -- Peter Dalgaard, Professor, Center for Sta
Re: [R] R 4.0.2 is released
My current version of R is 3.6.3, there is no problem of installing packages there. I also have no problem installing bioconductor packages with 3.6.3. But installing packages from biocondcutor failed as well on 4.0.2 (also tried 4.0.0 and failed, too) On Tuesday, June 23, 2020, 08:56:45 PM PDT, array chip via R-help wrote: Hi, I downloaded R4.0.2 and installed it succesffully without any error. However, when I opened up a R session (using x64) and tried to install packages, I got the following error message: > utils:::menuInstallPkgs() Warning: failed to download mirrors file (internet routines cannot be loaded); using local file 'C:/PROGRA~1/R/R-40~1.2/doc/CRAN_mirrors.csv' Warning: unable to access index for repository https://rweb.crmda.ku.edu/cran/src/contrib: internet routines cannot be loaded Error in install.packages(lib = .libPaths()[1L], dependencies = NA, type = type) : argument "pkgs" is missing, with no default In addition: Warning message: In download.file(url, destfile = f, quiet = TRUE) : unable to load shared object 'C:/PROGRA~1/R/R-40~1.2/modules/x64/internet.dll': LoadLibrary failure: Access is denied. > sessionInfo() R version 4.0.2 (2020-06-22) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18363) Matrix products: default locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.0.2 tools_4.0.2 However, if I load up a session using i386 verson, then everything is ok - I can install packages. Can you and anyone suggest what is going on? Thanks, John On Monday, June 22, 2020, 01:24:20 AM PDT, Peter Dalgaard via R-help wrote: The build system rolled up R-4.0.2.tar.gz (codename "Taking Off Again") this morning. The list below details the changes in this release. You can get the source code from http://cran.r-project.org/src/base/R-4/R-4.0.2.tar.gz or wait for it to be mirrored at a CRAN site nearer to you. Binaries for various platforms will appear in due course. For the R Core Team, Peter Dalgaard These are the checksums (md5 and SHA-256) for the freshly created files, in case you wish to check that they are uncorrupted: MD5 (AUTHORS) = b9c44f9f78cab3184ad9898bebc854b4 MD5 (COPYING) = eb723b61539feef013de476e68b5c50a MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343 MD5 (FAQ) = 4afa171cd982aaa60f0ba92e2e7bc5d6 MD5 (INSTALL) = 7893f754308ca31f1ccf62055090ad7b MD5 (NEWS) = 566a6bb3642e28e6bf01cf98db31137c MD5 (NEWS.0) = bfcd7c147251b5474d96848c6f57e5a8 MD5 (NEWS.1) = eb78c4d053ec9c32b815cf0c2ebea801 MD5 (NEWS.2) = 496062c138e2def06cebccddfb814ac6 MD5 (NEWS.3) = 012e7f4a80cc8ec947bf3f0ff6117ec8 MD5 (R-latest.tar.gz) = 1eac7293d5fe313a56ddabfda02b437e MD5 (README) = f468f281c919665e276a1b691decbbe6 MD5 (RESOURCES) = 529223fd3ffef95731d0a87353108435 MD5 (THANKS) = 251d20510bfc3cc93b82c5a99f7efcc6 MD5 (VERSION-INFO.dcf) = 62496d3a0fd8cc2ed644ea518c052371 MD5 (R-4/R-4.0.2.tar.gz) = 1eac7293d5fe313a56ddabfda02b437e 2cde824a7b18958e5f06b391c801c8288be0f84fa8934b7ddefef23c67e60c09 AUTHORS e6d6a009505e345fe949e1310334fcb0747f28dae2856759de102ab66b722cb4 COPYING 6095e9ffa777dd22839f7801aa845b31c9ed07f3d6bf8a26dc5d2dec8ccc0ef3 COPYING.LIB eddf87b12197c7b3b19cbc9b11c1beab95b14e3dcd715bf37d2f6a8b2a72c2a1 FAQ f87461be6cbaecc4dce44ac58e5bd52364b0491ccdadaf846cb9b452e9550f31 INSTALL ec05bba338358410fae6b34fed061605989ab3601aba1b3fcb45a610d5dd2eb9 NEWS 4e21b62f515b749f80997063fceab626d7258c7d650e81a662ba8e0640f12f62 NEWS.0 12b30c724117b1b2b11484673906a6dcd48a361f69fc420b36194f9218692d01 NEWS.1 e80de410c77f05ff2012fa70051b89119845f734a7fa5c55857e61e4ed7d5f6e NEWS.2 7201d139947afa52b5e09d26dc01445edf444506264355b2185122bc1ed3dce0 NEWS.3 d3bceab364da0876625e4097808b42512395fdf41292f4915ab1fd257c1bbe75 R-latest.tar.gz 2fdd3e90f23f32692d4b3a0c0452f2c219a10882033d1774f8cadf25886c3ddc README 408737572ecc6e1135fdb2cf7a9dbb1a6cb27967c757f1771b8c39d1fd2f1ab9 RESOURCES c9c7cb32308b4e560a22c858819ade9de524a602abd4e92d1c328c89f8037d73 THANKS 10cc5f566a4a5ce49147e7dcfbe9180dba09ccb9efb17298b067309eb799e92e VERSION-INFO.dcf d3bceab364da0876625e4097808b42512395fdf41292f4915ab1fd257c1bbe75 R-4/R-4.0.2.tar.gz This is the relevant part of the NEWS file CHANGES IN R 4.0.2: UTILITIES: * R CMD check skips vignette re-building (with a warning) if the VignetteBuilder package(s) are not available. BUG FIXES: * Paths with non-ASCII characters caused problems for package loading on Windows PR#17833. * Using tcltk widgets no longer crashes R on Windows. * source(*, echo=TRUE) no longer fails in some cases with em
[R] How to generate this type of scatter plots in R
Hello everyone, I saw this scatterplots from a paper and thought it looked very nice: https://drive.google.com/file/d/1V7F1gq-J_GIFDOrJs00hwGyXUqCZ_xwa/view?usp=sharing It was similar to stripchart() with 'jitter' method, but it has a special pattern of aligning points which made it look nicer than standard stripchart(). Does anyone know if there is a package in R that can do this kind of plots? 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] how to generate this kind of graph
Hello everyone, I saw this scatterplots from a paper and thought it looked very nice: https://drive.google.com/file/d/1V7F1gq-J_GIFDOrJs00hwGyXUqCZ_xwa/view?usp=sharing It was similar to stripchart() with 'jitter' method, but it has a special pattern of aligning points which made it look nicer than standard stripchart(). Does anyone know if there is a package in R that can do this kind of plots? 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] R rounding problem?
Hello, I made a mistake today on simple counting in R, that almost got me into trouble. After trying multiple times, I finally figured out it's rounding issue in R. For exmaple, when I just simply type: > (6.9-6.3) > 0.6 [1] TRUE 6.9-6.3 should be 0.6 exactly, but R thinks that it's greater than 0.6!! Similarly, R thinks 5.6-5.5 is smaller than 0.1: > (5.6-5.5) < 0.1 [1] TRUE Why is the above happening? This rounding issue seems to be small, but this could cause serious problem in real world. Can anyone shed a light on how to avoid the issue? Thanks, Yi __ 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] [External] R rounding problem?
Thanks Richard. Got it now... On Thursday, September 3, 2020, 10:12:36 PM PDT, Richard M. Heiberger wrote: FAQ 7.31 On Fri, Sep 4, 2020 at 12:47 AM array chip via R-help wrote: > > Hello, > > I made a mistake today on simple counting in R, that almost got me into > trouble. After trying multiple times, I finally figured out it's rounding > issue in R. > > For exmaple, when I just simply type: > > > (6.9-6.3) > 0.6 > [1] TRUE > > 6.9-6.3 should be 0.6 exactly, but R thinks that it's greater than 0.6!! > > Similarly, R thinks 5.6-5.5 is smaller than 0.1: > > > (5.6-5.5) < 0.1 > [1] TRUE > > Why is the above happening? This rounding issue seems to be small, but this > could cause serious problem in real world. > > Can anyone shed a light on how to avoid the issue? > > Thanks, > > Yi > > __ > 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.