No need for computer-intensive loops. Try the following:
a <- data.frame(x = c(1,2,3,4), y = c(1,2,1,2))
xx=data.frame(x.1=a[,1],x.2=2*a[,1])
yy=data.frame(y.1=a[,2],y.2=2*a[,2])
Cheers
Francisco
>From: "Apoian, Zack" <Zack.Apoian at sac.com>
>To: <r-help at stat.math.ethz.ch>
>Subject: [R] data frame output in loops
>Date: Fri, 6 May 2005 14:56:21 -0400
>
>I know this is very basic--I'm wondering if there is a way to write
data
>frames as outputs from a loop.
>In other words, take this simple example:
>
> > a <- data.frame(x = c(1,2,3,4), y = c(1,2,1,2))
>
>Given a, how would you write a loop that creates two data frames, x and y,
>where the first column is a column of a and the second column is two times
>the first column, or:
>
> > x
> x.1 x.2
>1 1 2
>2 2 4
>3 3 6
>4 4 8
>
>
>and
>
> > y
> y.1 y.2
>1 1 2
>2 2 4
>3 1 2
>4 2 4
>
>
>
>
>DISCLAIMER: This e-mail message and any attachments are inte...{{dropped}}
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide!
>http://www.R-project.org/posting-guide.html