Re: [R] [FORGED] p-value=0 running log-rank test

2017-05-18 Thread Rolf Turner
This is not an R question. Your question indicates that you really need to learn some statistics. To answer the very last part: > pchisq(430,3,lower=FALSE) [1] 7.020486e-93 And if that is not 0 to all intents and purposes, then God help us all. cheers, Rolf Turner On 19/05/17 12:48, Anne K

[R] p-value=0 running log-rank test

2017-05-18 Thread Anne Karin da Mota Borges
Dear all, I have a question concerning the p-value. When running log-rank test I get a p-value = 0. What is it mean? Can this be true? Why aren´t there decimal points? Is there a way to find out the exact p-value? Here is the output: > survdiff(Surv(tempo2,status)~tphist, data=base,rho=0) Call:

Re: [R] Question about change the length of a string.

2017-05-18 Thread Yen Lee
Hi Jeff, Thank you a lot! Best, Yen -Original Message- From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us] Sent: Thursday, May 18, 2017 11:11 PM To: r-help@r-project.org; Yen Lee Subject: Re: [R] Question about change the length of a string. http://stackoverflow.com/questions/2

Re: [R] Question about change the length of a string.

2017-05-18 Thread Jeff Newmiller
http://stackoverflow.com/questions/2261079/how-to-trim-leading-and-trailing-whitespace-in-r -- Sent from my phone. Please excuse my brevity. On May 18, 2017 8:57:51 PM PDT, Yen Lee wrote: >Hello everyone, > > > >I have a question and I need your precious kind help. > > > >I am working on matc

[R] Question about change the length of a string.

2017-05-18 Thread Yen Lee
Hello everyone, I have a question and I need your precious kind help. I am working on matching two string. However, the length of the two strings is different. For example, one is "example" (nchar=7), the other one is "example " (nchar=10). The R considers them as different strings but t

Re: [R] RCommander issue

2017-05-18 Thread Jim Lemon
Hi Thambu, Try downloading the package from CRAN. For example, I just tried this with the rgdal package as I need to use it. The package (rgdal_1.2-7.zip) is saved on the local hard disk. Then find out where your R executable is. For me it is: E:\jim\R\R-3.3.3\bin\x64\R.exe Now open a "Command P

[R] S4 Question; show generic method

2017-05-18 Thread stephen sefick
Hello, I changed the name of a function, and updated my R packages with update.packages(ask=FALSE), and I have had a curious (to me) change in show method. I am developing a package, and a generic show method I defined for my S4 class is not autocalled when I type the object name - object_name; ho

Re: [R] Extracting metadata information to corresponding dissimilarity matrix

2017-05-18 Thread Rune Grønseth
Brilliant, David, thank you so much! Cheers, Rune > 16. mai 2017 kl. 18.44 skrev David L Carlson : > > Fixing a typo in the original, adding a simplification, and using > dissimilarity instead of similarity: > > set.seed(42) > dta <- data.frame(ID=1:7, gender=sample(c("M", "F"), 7, replace=

Re: [R] Randomly select one row by group from a matrix

2017-05-18 Thread David L Carlson
You can modify your original code to get what you want: do.call(rbind, lapply(split(data.frame(test), test[,c("id")]), function(x) as.matrix(x[sample(nrow(x), 1), ]))) # xcor ycor id # 146 1 # 242 2 But Bert's way is simpler: indx <- tapply(seq_along(test[, "id"]), test[, "i

Re: [R] Randomly select one row by group from a matrix

2017-05-18 Thread Bert Gunter
If I understand corrrectly, this is easily accomplished in base R via ?tapply and indexing. e.g. set.seed(1234) ## for reproducibility grp <- sample.int(5,size = 30,rep = TRUE) ## a grouping vector ## Could be just a column of your matrix or frame indx <- tapply(seq_along(grp),grp, sample,size =

Re: [R] Randomly select one row by group from a matrix

2017-05-18 Thread Ulrik Stervbo
Hi Marine, your manipulation of the matrix is quite convoluted, and it helps to expand a bit: test_lst <- split(test, test[,c("id")]) test_lst$`1` after splitting, your matrix has gone back to be a plain vector, which makes the sampling fail. The reason is that, a matrix - behind the scenes - i

[R] Randomly select one row by group from a matrix

2017-05-18 Thread Marine Regis
Hello, I would like to randomly select one row by group from a matrix. Here is an example where there is one row by group. The code gives an error message: test <- matrix(c(4,4, 6,2, 1,2), nrow = 2, ncol = 3, dimnames = list(NULL, c("xcor", "ycor", "id"))) do.call(rbind, lapply(split(test, test[,

Re: [R] violin plot help

2017-05-18 Thread Ismail SEZEN
> On 16 May 2017, at 17:06, Abdelrahman, Omar (RER) > wrote: > > I am trying to produce multiple violin plots by 3 categorical variables, each > violin representing 1 year worth of data. The variables are: > > Watershed (7 levels: county canals) > > Geography (5 levels: west; central; east;

Re: [R] violin plot help

2017-05-18 Thread Abdelrahman, Omar (RER)
Many thanks Jeff! I knew it would require a loop approach, so I will now explore that with the code you suggested. -Original Message- From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us] Sent: Wednesday, May 17, 2017 5:19 PM To: Abdelrahman, Omar (RER) ; R-help Subject: RE: [R] violi

Re: [R] Help on reducing multiple loops

2017-05-18 Thread John Kane via R-help
Data? It's difficult to do anything without some test data.See How to make a great R reproducible example? or http://adv-r.had.co.nz/Reproducibility.html  with particular reference to the use of dput() as the best way to provide sample data. | | | | || | | | | | Ho

Re: [R] converting each column of a data frame into a matrix with n rows

2017-05-18 Thread Davide Piffer
Thanks David! It worked! On 17 May 2017 at 23:39, David Winsemius wrote: > >> On May 17, 2017, at 1:01 PM, Davide Piffer wrote: >> >> Thanks! This gets closer to the solution but a small problem remains. >> I get 2 rows and only one column, whereas I need a 2x2 matrix (like a >> contingency tabl