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

2010-06-07 Thread moleps
lp-boun...@r- >> project.org] On Behalf Of moleps >> Sent: Sunday, June 06, 2010 1:51 PM >> To: r-help@r-project.org >> Subject: [R] paste together a string object later to be utilized in a >> function >> >> Dear r-listers, >> >> I need to pass a string

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

2010-06-07 Thread Greg Snow
ct.org [mailto:r-help-boun...@r- > project.org] On Behalf Of moleps > Sent: Sunday, June 06, 2010 1:51 PM > To: r-help@r-project.org > Subject: [R] paste together a string object later to be utilized in a > function > > Dear r-listers, > > I need to pass a string to a function.

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

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

2010-06-06 Thread moleps
Dear r-listers, I need to pass a string to a function. However the length of the string is dependent on the length of a vector. b<-length(h) v<-paste("rep(names(ts$a[",1:b,"]),ts$a[",1:b,"])",sep="") Is it possible somehow to pass this as an argument to a function later on ? Regards, //