Re: [R] paste together a string object later to be utilized in a function

2010-06-07 Thread moleps
Sorry for bothering all of you. In the end it turned out to be much simpler than I thought. Takes a while to get used to the vectorizing idea. require(survival) require(ggplot2) ggkm<-function(time,event,stratum) { stratum<-as.factor(stratum) m2s<-Surv(time,as.numeric

Re: [R] paste together a string object later to be utilized in a function

2010-06-07 Thread Greg Snow
Does the collapse argument to the paste function do what you want? Possibly nested inside another paste. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -Original Message- > From: r-help-boun...@r-project.org [mailto:

Re: [R] paste together a string object later to be utilized in a function

2010-06-07 Thread Joris Meys
It helps if you provide sample data, so we can try some things out ourselves. Right now, I can't run your function without guessing how your data might look like. Yet, try something like this : > ts <- list(a=1:5) > names(ts$a) <- letters[1:5] > n <- length(names(ts$a)) > tmp <- sapply(1:n,func

Re: [R] paste together a string object later to be utilized in a function

2010-06-07 Thread moleps islon
I'm sorry for not clearer describing my motive with this-- So this is what I'm trying to do- Take a survival object and utilize it in ggplot. ggkm<-function(time,event,stratum) { m2s<-Surv(time,as.numeric(event)) fit <- survfit(m2s ~ stratum) f$time<-fit$time f$surv<-fit$surv

Re: [R] paste together a string object later to be utilized in a function

2010-06-06 Thread Joris Meys
Wild guess, but it looks like you are looking at : > ts <- list(a=1:5) > names(ts$a) <- letters[1:5] > v<-paste("rep(names(ts$a[",1:b,"]),ts$a[",1:b,"])",sep="") > > sapply(v,function(x){eval(parse(,text=x))}) $`rep(names(ts$a[1]),ts$a[1])` [1] "a" $`rep(names(ts$a[2]),ts$a[2])` [1] "b" "b" $`re