Serguei Kaniovski wrote:
> Say I have a FOR-loop for computing powers (just a trivial example)
>
> for(i in 1:5)
> {
> x<-i^2
> y<-i^3
> }
>
> How can I create a data.frame and a 3D plot of (i,x(i),y(i)), i.e. for
> each iteration
>
> Thanks,
> Serguei Kaniovski
If thats all you really need:
data<- t(sapply(1:5, function(i){ return(c(i,i^2,i^3))}))
scatterplot3d(data)
In general you don't plot something in R for each iteration.
You rather pass the whole result to the plot function.
But there are plotting function which accept formulas.
Regards,
Ido Tamir
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html