Re: [R] Coding columns for survival analysis

2012-04-16 Thread Alexander Shenkin
Jim, This was very helpful - thank you! I really like the use of diff and cumsum - those haven't been in my toolkit until now. Your solution came close, but I needed to keep "NAs" when the tree hadn't been found yet, or when it had already died. So, for posterity, here's the code I ended up wit

Re: [R] Coding columns for survival analysis

2012-04-13 Thread jim holtman
try this: > x <- read.table(text = " tree live1 live2 live3 live4 live5 +1 tree1 0 0 0 1 1 +2 tree2 0 0 1 1 0 +3 tree3 0 1 1 0 0 +4 tree4 1 1 0 0 0 +6 tree4 1 1 1 1 0 # anothe

[R] Coding columns for survival analysis

2012-04-13 Thread Alexander Shenkin
Hello Folks, I have 5 columns for thousands of tree records that record whether that tree was alive or dead. I want to recode the columns such that the cell reads "found" when a live tree is first observed, "alive" for when a tree is found alive and is not just found, and "mort" when it was previ