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" $`rep(names(ts$a[3]),ts$a[3])` [1] "c" "c" "c" $`rep(names(ts$a[4]),ts$a[4])` [1] "d" "d" "d" "d" $`rep(names(ts$a[5]),ts$a[5])` [1] "e" "e" "e" "e" "e" > assign("test",eval(parse(text=v[3]))) > test [1] "c" "c" "c" > Cheers Joris On Sun, Jun 6, 2010 at 9:51 PM, moleps <mole...@gmail.com> wrote: > 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, > > //M > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control tel : +32 9 264 59 87 joris.m...@ugent.be ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.