Hi Greg,
One problem is that you have misplaced the closing brace in the third
loop. It should follow the assignment statement. Because you used
loops rather than Bert's suggestion, perhaps you are trying to order
the values assigned. In your example, the ordering will be ssn, then
month of birth,
Hello,
Bert's modular arithmetic way simplifies my code a lot.
breakVec <- function(x, n = 5){
if(n < 1) stop(paste("Illegal value n:", n))
f <- if(n == 1) "" else (seq_along(x) - 1) %/% n
split(x, f)
}
Hope this helps,
Rui Barradas
Às 20:08 de 18/08/19, Bert Gunter escreveu:
Perhaps
id <- do.call(paste0,expand.grid(0:9, 1:3, 1:5))
Comment: If you use R much, you'll do much better using R language
constructs than trying to apply those from other languages (Java perhaps?).
I realize this can be difficult, especially if you are experienced in the
another language (or languages),
Perhaps simpler:
Hint: (seq_along(LETTERS) -1) %/% 5
## modular arithmetic can be useful for this sort of thing
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 )
O
I would like to create pseudo identification numbers in the format of last
four of a social security number ( to ), month of birth (01 to 12),
and day of birth (01-28). The IDs can be character.
I have gotten this far:
for (ssn in 0:9){
for (month in 1:3){
for (day in 1:5){
Hi, Christofer,
try something along
len <- 5
split(Vec, rep(seq(ceiling(length(Vec)/len)), each = len))
Hth -- Gerrit
-
Dr. Gerrit Eichner Mathematical Institute, Room 212
gerrit.eich...@math.uni-giessen.d
Hello,
The following function will do it.
It uses a standard cumsum trick to create a break vector f.
And predicts special cases (n = 0 or n = 1).
breakVec <- function(x, n = 5){
if(n < 1) stop(paste("Illegal value n:", n))
if(n == 1){
f = ""
}else{
f <- c(1, rep(0, n - 1))
f <
Hi,
Let say I have a vector as below
Vec = LETTERS
Now I want to break this vector into groups of the same length of 5.
So,
1st group consists - "A" "B" "C" "D" "E"
2nd group - "F" "G" "H" "I" "J"
and so on..
last group will consist only the leftover elements
I have a very large initial vecto
Dear All,
Consider the following simple example:
library( survival )
data( veteran )
coef( coxph(Surv(time, status) ~ trt + prior + karno, data = veteran) )
trtpriorkarno
0.180197194 -0.005550919 -0.033771018
Note that we have neither time-dependent covariates, nor ti
Dear Dr. Therneau,
Thank you very much for your exhaustive answer!
I now see the issue. Perhaps even more important was your confirmation that my
approach with karno:ns(time, df=4) is theoretically correct. (I knew that
plot.cox.zph is sound, so I was afraid that the difference can be attribute
10 matches
Mail list logo