"Hotz, T." <[EMAIL PROTECTED]> writes:
> Dear Tobias,
>
> The trick is "Programming on the Language", see e.g. the "R Language Manual".
> Construct the expression you want, and have it explicitly parsed and evaluated.
>
> toy <- function(b=.95){
> toyframe <- eval(parse(text=paste("data.frame(lion", b, " = c(1, 2))", sep="")))
> return(toyframe)
> z}
> toy()
> toy(0)
A bit of an overkill in this case:
toy <- function(b=.95){
toyframe <- data.frame(x=c(1,2))
names(toyframe) <- paste("lion",b,sep="")
toyframe
}
(Getting rid of the leading 0 is left as an exercise...)
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907
______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help