[R] data frame output in loops

From: Apoian, Zack <Zack.Apoian_at_sac.com>
Date: Sat 07 May 2005 - 04:56:21 EST


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@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 Received on Sat May 07 05:03:28 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:37 EST