Re: [R] using a variable in a subset of a dataframe

From: K. Elo <maillists_at_nic.fi>
Date: Tue, 01 Apr 2008 21:53:09 +0300

Henrique Dallazuanna wrote (1.4.2008):
> You can try this:
>
> x <- data.frame()
> for(i in LETTERS[1:5]) x[1:10, i] <- rnorm(10)
> x

Or this:

How 'df' changes:
Step 1:
> df

  X0
1 0

Step 2 (for-loop):
> df

  X0 1 2 3 4 5 6 7 8 9 10
1 0 0 0 0 0 0 0 0 0 0 0

Is this what You are looking for?

Kind regards,
Kimmo



R-help_at_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. Received on Tue 01 Apr 2008 - 20:10:06 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 01 Apr 2008 - 22:30:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive